Skip to main content
cancel
Showing results for 
Search instead 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

Reply
micpete
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
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
v-yifanw-msft
Community Support
Community Support

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
Europe Fabric Conference

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 Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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