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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Modelling Duration

Hi there,

 

Very new to PowerBI and I'm trying to model a column of data so that I may use the a SUM to total hours logged in a report.  I have been able to set the data type to Time, but not Duration and therfore SUM is not an option.

 

Any help appreciated.

 

Powerbi-duration-help.PNG

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

You could refer this thread to sum a "time" column.

https://community.powerbi.com/t5/Desktop/Sum-of-H-MM-SS/td-p/124007

 

For example, if you want to sum the "time" column based on each date, you can try the example below

Capture1.JPG

SumTalkTime = 

VAR TotalSeconds=SUMX(FILTER('Table','Table'[date]=EARLIER('Table'[date])),HOUR('Table'[Column])*3600+MINUTE('Table'[Column])*60+SECOND('Table'[Column]))
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)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

You could refer this thread to sum a "time" column.

https://community.powerbi.com/t5/Desktop/Sum-of-H-MM-SS/td-p/124007

 

For example, if you want to sum the "time" column based on each date, you can try the example below

Capture1.JPG

SumTalkTime = 

VAR TotalSeconds=SUMX(FILTER('Table','Table'[date]=EARLIER('Table'[date])),HOUR('Table'[Column])*3600+MINUTE('Table'[Column])*60+SECOND('Table'[Column]))
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)
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ibarrau
Super User
Super User

Hi, no worries. Go to edit queryes, pick the type Time column and the go to "Add Column" Tab. Check the right top corner you will find options for the hour/time. This will create a new column of the operation option you choose. Then you can sum that column.

 

Regards, hope this helps,

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


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

Happy to help!

LaDataWeb Blog

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.