cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Regular Visitor

## Sum of Duration in hours

Hello,

I need some help, I have data from a SQL that gives me total hours (up to 24), I have worked out some of hours by using measure,

CALCULATE(SUM(table)), this gives me sum of hours however total sums can be over 24 hours - I tried coverting to duration which gives me over 24 hours but it then converts mins into decimal instead of time, e.g. 25.90 which is 25 hours and 90 mins, but I want that to be duration i.e. if it's 25 hours and 90 mins then I prefer that to be 26 hrs and 30 mins - which would be sum of duration. How do I do this?
1 ACCEPTED SOLUTION
Super User

Hi @micpete ,

One approach to do this is first converting everyting into minutes, then do the sum, then convert back into hours and minutes. Unfortunately working with durations in DAX is not as convenient as in PowerQuery.

Calcualted column:

TimeMinutes = [hours]*60+[minutes]

Measures:

TotalDuration = SUM(table[TimeMinutes])

TotalHours = INT(DIVIDE([TotalDuration],60))

TotalMinutes = [TotalDuration]-[TotalHours]*60

Kind regards,

Martin

2 REPLIES 2
Community Support

Hi @micpete  ,
May I ask if you have tried the suggestions above? If the suggestion helped you, you might consider marking it as a solution. If the problem has not yet been solved, please feel free to ask us a question.

Best Regards,

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Super User

Hi @micpete ,

One approach to do this is first converting everyting into minutes, then do the sum, then convert back into hours and minutes. Unfortunately working with durations in DAX is not as convenient as in PowerQuery.

Calcualted column:

TimeMinutes = [hours]*60+[minutes]

Measures:

TotalDuration = SUM(table[TimeMinutes])

TotalHours = INT(DIVIDE([TotalDuration],60))

TotalMinutes = [TotalDuration]-[TotalHours]*60

Kind regards,

Martin

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors