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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Skyler
Regular Visitor

Sum of HH:MM:SS issue

Hi,

Please assist me, i'm having an issue where my duration is not suming correctly, hours are showing on minutes and minutes on seconds

 

DAX used: Duration =
VAR Duration = SUM(Duration])
VAR Hours =
INT ( Duration / 3600) ------//when i divided with 60 the hours come right and the minutes move to seconds.//
VAR Minutes =
INT ( MOD( Duration - ( Hours * 3600 ),3600 ) / 60)
VAR Seconds =
ROUNDUP(MOD ( MOD( Duration - ( Hours * 3600 ),3600 ), 60 ),0)
VAR H =
IF ( LEN ( Hours ) = 1,
CONCATENATE ( "0", Hours ),
CONCATENATE ( "", Hours )
)
VAR M =
IF (
LEN ( Minutes ) = 1,
CONCATENATE ( "0", Minutes ),
CONCATENATE ( "", Minutes )
)
VAR S =
IF (
LEN ( Seconds ) = 1,
CONCATENATE ( "0", Seconds ),
CONCATENATE ( "", Seconds )
)
RETURN
CONCATENATE (
H,
CONCATENATE ( ":", CONCATENATE ( M, CONCATENATE ( ":", S ) ) )
)

Below is the output:

Skyler_0-1705573046160.png

 

When i divided hours with 60 instead of 3600, theres a slight improvment, but my minutes and seconds are off. 

Skyler_2-1705574085347.png

 

Scenerio two: Rows are not suming correctly but when i open the drop down, hh::mm:ss is correct unlike scenerio one, but the total is incorrect also.

Dax used: 

Activity Length = // We start with a duration in number of seconds
VAR Duration = IF(
        ISBLANK([Lat Sch Activity]),BLANK(),
        [Lat Sch Activity]

)

VAR Hours =
    INT ( Duration / 60)

VAR Minutes =
    MOD( Duration,60)

VAR Seconds =
    INT((Duration - INT(Duration)) *60)
VAR H = IF(
    ISBLANK(DURATION),BLANK(),
    IF ( LEN ( Hours ) = 1,
        CONCATENATE ( "0", Hours ),
        CONCATENATE ( "", Hours )
      ))
// Minutes with leading zeros
VAR M = IF(
    ISBLANK(DURATION),BLANK(),
    IF (
        LEN ( Minutes ) = 1,
        CONCATENATE ( "0", Minutes ),
        CONCATENATE ( "", Minutes )
    ))
// Seconds with leading zeros
VAR S = IF(
    ISBLANK(DURATION),BLANK(),
    IF (
        LEN ( Seconds ) = 1,
        CONCATENATE ( "0", Seconds ),
        CONCATENATE ( "", Seconds )
    ))
// Now return hours, minutes and seconds with leading zeros in the proper format "hh:mm:ss"
//RETURN
VAR Time =
    IF(
        (ISBLANK(H) && ISBLANK(M) && ISBLANK(S)),BLANK(),
        (CONCATENATE (
        H,
        CONCATENATE ( ":", CONCATENATE ( M, CONCATENATE ( ":", S ) ) )
                    )
        )
)

RETURN
    IF(
        AND((ISBLANK(Time)),([Lat Sch Activity]) == 0),
        "00:00:00",
        Time
    )
 
Below is the output:
Skyler_1-1705573691753.png
 Your help will be appreciated.
1 REPLY 1
_elbpower
Resolver III
Resolver III

This might work:

Scenerio 1:

 

Duration =
VAR Duration = SUM('Model Table'[Duration]) // OR [Lat Sch Activity]
VAR Hours = INT(Duration / 3600)
VAR Minutes = INT(MOD(Duration - (Hours * 3600), 3600) / 60)
VAR Seconds = MOD(MOD(Duration - (Hours * 3600), 3600), 60)
RETURN FORMAT(Hours, "00") & ":" & FORMAT(Minutes, "00") & ":" & FORMAT(Seconds, "00")

 




Scenerio 2:

 

Activity Length =
VAR Duration = IF(ISBLANK([Lat Sch Activity]), BLANK(), [Lat Sch Activity])
VAR Hours = INT(Duration / 3600)
VAR Minutes = INT(MOD(Duration, 3600) / 60)
VAR Seconds = MOD(MOD(Duration, 3600), 60)
RETURN IF(
    ISBLANK(Duration),
    BLANK(),
    FORMAT(Hours, "00") & ":" & FORMAT(Minutes, "00") & ":" & FORMAT(Seconds, "00")
)

 


Make sure to replace 'Model Table' with the actual name of your table in both formulas. If you still encounter issues, please provide more details about the data and the structure of your table.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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