Forum Discussion
Anonymous
7 years agoNot applicable
convert seconds column into duration column mm:ss
I tried the following DAX query, but its not given as a expected output
Mins : Sec =
VAR Duration = sum(TABLE1[seconds])
VAR Minutes =
INT ( MOD( Duration,3600 ) / 60)
VAR Seconds =
ROUNDUP(MOD ( MOD( Duration,3600 ), 60 ),0) // We round up here to get a whole number
// Minutes with leading zeros
VAR M =
IF (
LEN ( Minutes ) = 1,
CONCATENATE ( "0", Minutes ),
CONCATENATE ( "", Minutes )
)
// Seconds with leading zeros
VAR S =
IF (
LEN ( Seconds ) = 1,
CONCATENATE ( "0", Seconds ),
CONCATENATE ( "", Seconds )
)
// Now return minutes and seconds with leading zeros in the proper format "mm:ss"
RETURN
CONCATENATE ( M, CONCATENATE ( ":", S ) )
Following table i had.
Name seconds Mins:sec
Abi 500 18:05
Emi 250 18.05
Note : Mins: sec column wrongly written as an expected output
konstantinos and I wrote an article this a long time ago, pluse I'm pretty sure there is something in the Quick Measure gallery for this:
https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486
https://community.powerbi.com/t5/Quick-Measures-Gallery/Seconds-2-HHMMSS/m-p/195615
1 Reply
- Greg_Deckler
Community Champion
konstantinos and I wrote an article this a long time ago, pluse I'm pretty sure there is something in the Quick Measure gallery for this:
https://community.powerbi.com/t5/Community-Blog/Aggregating-Duration-Time/ba-p/22486
https://community.powerbi.com/t5/Quick-Measures-Gallery/Seconds-2-HHMMSS/m-p/195615