Time Calculation Summing Work Hours

Hello Everyone,

I’m trying add hours per day together to find the total hours
Example:
Monday 8 hours
Tuesday 7 hours
Wednesday 10 hours

Total hours 25 hours

I’m looking in the Learning Center did not find anythng.
It would be great to have something about time calculations.

Here is my Power BI File and screen shot

I’m trying to get the total hours for Customer A, B, C, D

Duration.pbix (22.2 KB)

As you can see Duration Sum is incorrect. How do I do this ?

Here is the CSV Data if you need it.
DurationSampleData.csv (3.0 KB)

Hi @ericet

I believe it’s because of how time values are represented behind the scenes, so when you sum them it doesn’t give what you’d expect.

I made a measure that converts your time into a decimal e.g. 07:30:00 showing as 7.5:

Duration Hour Minute =
//Find hour of time
VAR _Hour = HOUR( SELECTEDVALUE( DurationSampleData[Duration] ) )

//Find minute as proportion of hour
VAR _Minute = DIVIDE(MINUTE( SELECTEDVALUE( DurationSampleData[Duration] ) ), 60, 0 )

//Add together
VAR _Result = _Hour + _Minute

RETURN
_Result

Then a measure to sum it up:

Duration Sum v2 = SUMX( DurationSampleData, DurationSampleData[Duration Hour Minute] )

That gave the below:
image

Duration.pbix (22.7 KB)

3 Likes

Yes, thank you so much !

That solved my problem, and will help others I’m sure.

Thanks again