Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi all,
I need to calculate the SUM of hours and display it as excel format 37:30:55, however when I perfom the sum when it over pass 24, it starts return the count to zero. example if the sum of the hours is 26hours and 15 min is wrongly returning as 2:15:00 ideally it should displayed as 26:15:00.
If I change the data type to duration, it displays as 1.02:15:00. Is there any way to return it as it's possible in excel format as 26:15:00 ?
Solved! Go to Solution.
@Anonymous
What does your duration data look like in the table? If you have the values in seconds you can use something like this.
Call Duration:=
VAR _Seconds = [Call Duration Seconds]
VAR _Minutes = INT ( DIVIDE ( _Seconds, 60 ) )
VAR _RemainingSeconds = MOD ( _Seconds, 60 )
VAR _Hours = INT ( DIVIDE ( _Minutes, 60 ) )
VAR _RemainingMinutes = MOD ( _Minutes, 60 )
RETURN
IF (
NOT ISBLANK ( [Call Duration Seconds] ),
FORMAT ( _Hours, "00" ) & ":" &
FORMAT ( _RemainingMinutes, "00" ) & ":" &
FORMAT ( _RemainingSeconds, "00" )
)
When the time goes over 24 hours the measure looks like this:
[Call Duration Seconds] used in the first var is just the sum of the seconds column on the call_log table.
Hi @Anonymous ,
Have you tried the format function?
myHours =
FORMAT(
SUM(table[hours]),
"hh:mm"
)
Not sure this will work for you but worth a shot.
Pete
Proud to be a Datanaut!
@Anonymous
What does your duration data look like in the table? If you have the values in seconds you can use something like this.
Call Duration:=
VAR _Seconds = [Call Duration Seconds]
VAR _Minutes = INT ( DIVIDE ( _Seconds, 60 ) )
VAR _RemainingSeconds = MOD ( _Seconds, 60 )
VAR _Hours = INT ( DIVIDE ( _Minutes, 60 ) )
VAR _RemainingMinutes = MOD ( _Minutes, 60 )
RETURN
IF (
NOT ISBLANK ( [Call Duration Seconds] ),
FORMAT ( _Hours, "00" ) & ":" &
FORMAT ( _RemainingMinutes, "00" ) & ":" &
FORMAT ( _RemainingSeconds, "00" )
)
When the time goes over 24 hours the measure looks like this:
[Call Duration Seconds] used in the first var is just the sum of the seconds column on the call_log table.
Do you know why the yellow lines below are giving the wrong value?
@jdbuchanan71 it worked perfectly.
My hours was in decimal , so I've converted it to seconds (multiplying by 3600) and then used it on the formula.
If your duration is more like hh:mm:ss you can get the duration in seconds by adding a calculated column that is the duration / (1/86400). 86400 is the number of seconds in a day so taking 36:10:15 returns 130215 just like it would in excel.
Then you can sum that to get the [Duration in seconds] measure used in my example.
User | Count |
---|---|
123 | |
69 | |
67 | |
58 | |
52 |
User | Count |
---|---|
183 | |
92 | |
67 | |
62 | |
53 |