Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
micpete
Helper III
Helper III

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
Martin_D
Super User
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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Thank you @Martin_D  for your prompt reply.

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,

Ada Wang

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

Martin_D
Super User
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

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.