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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
maurcoll
Helper III
Helper III

sum of time in hours and minutes

Hi i have the below dax calculation
I have a start time and end time and difference between the two, all columns are formatted as Time

Sum Duration =

VAR TotalSeconds=SUMX('Duration',HOUR('Duration'[Time])*3600 +MINUTE('Duration'[Time])*60+SECOND('Duration'[Time]))
VAR Days =TRUNC(TotalSeconds/3600/24)
VAR Hors = TRUNC((TotalSeconds-Days*3600*24)/3600)
VAR Mins =TRUNC(MOD(TotalSeconds,3600)/60)
VAR Secs = MOD(TotalSeconds,60)
return
IF(DAYS=0,"",IF(DAYS>1,DAYS&"days ",Days&"day"))
&
IF(Hors<10,"0"&Hors,Hors)&":"&IF(Mins<10,"0"&Mins,Mins)&":"&IF(Secs<10,"0"&Secs,Secs)

This gives me the correct value but in days, hours, minutes. I only want the value to be in hours and minutes.
So the result i am getting is 2d 18:39 what i want is  66:39, how can i change the above to get the result i need.
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@maurcoll Try:

VAR TotalSeconds=SUMX('Duration',HOUR('Duration'[Time])*3600 +MINUTE('Duration'[Time])*60+SECOND('Duration'[Time]))
VAR Days =TRUNC(TotalSeconds/3600/24)
VAR Hors = TRUNC((TotalSeconds-Days*3600*24)/3600) + (Days * 24)
VAR Mins =TRUNC(MOD(TotalSeconds,3600)/60)
VAR Secs = MOD(TotalSeconds,60)
return
IF(Hors<10,"0"&Hors,Hors)&":"&IF(Mins<10,"0"&Mins,Mins)&":"&IF(Secs<10,"0"&Secs,Secs)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

1 REPLY 1
Greg_Deckler
Community Champion
Community Champion

@maurcoll Try:

VAR TotalSeconds=SUMX('Duration',HOUR('Duration'[Time])*3600 +MINUTE('Duration'[Time])*60+SECOND('Duration'[Time]))
VAR Days =TRUNC(TotalSeconds/3600/24)
VAR Hors = TRUNC((TotalSeconds-Days*3600*24)/3600) + (Days * 24)
VAR Mins =TRUNC(MOD(TotalSeconds,3600)/60)
VAR Secs = MOD(TotalSeconds,60)
return
IF(Hors<10,"0"&Hors,Hors)&":"&IF(Mins<10,"0"&Mins,Mins)&":"&IF(Secs<10,"0"&Secs,Secs)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.