We're giving away 30 tickets for FREE! Share your story, your vision, or your hustle and tell us why YOU deserve a ticket.
Apply nowWin a FREE 3 Day Ticket to FabCon Vienna. Apply now
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:
When i divided hours with 60 instead of 3600, theres a slight improvment, but my minutes and seconds are off.
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:
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.
User | Count |
---|---|
13 | |
12 | |
8 | |
8 | |
6 |
User | Count |
---|---|
28 | |
19 | |
13 | |
11 | |
7 |