Forum Discussion
i820017
5 years agoResolver II
Convert Decimal Number to Mins:Seconds
Hey Everybody,
I am trying to convert a decimal number into mm:ss in Power BI.
I tried using the following measure
VAR _Seconds = [ASA]
VAR _Minutes = INT ( DIVIDE ( _Seconds, 60 ) )
VAR _RemainingSeconds = MOD ( _Seconds, 60 )
VAR _RemainingMinutes = MOD ( _Minutes, 60 )
RETURN
IF (
NOT ISBLANK ( [ASA] ),
FORMAT ( _RemainingSeconds, "00" ) & ":" &
FORMAT ( _RemainingMinutes, "00" )
)
The measure above yielded the following.
As you can see, my answer is rounding to the nearest minute. I need it to give the time in mm:ss.
Can anyone help with this?
Thanks
Dan
I used an entirely different measure, and it worked.
Here is the measure that I used.
ASA4 =VAR Duration = [ASA]VAR Minute_ = INT ( [ASA] )VAR Seconds =ROUNDUP( ([ASA] - Minute_ ) * 60 ,0)VAR M =IF (LEN ( Minute_ ) = 1,CONCATENATE ( "0", Minute_ ),CONCATENATE ( "", Minute_ ))VAR S =IF (LEN ( Seconds ) = 1,CONCATENATE ( "0", Seconds ),CONCATENATE ( "", Seconds ))"RETURN IF(NOT ISBLANK([ASA]),CONCATENATE ( M, CONCATENATE ( ":", S ) ) , "00:00")
3 Replies
- amitchandakSuper User
i820017 , Try like
FORMAT ( quotient([_Seconds],60), "00" ) & ":" & FORMAT ( mod(_Seconds,60), "00" )
- i820017Resolver II
That didn't work. This is my output.
- i820017Resolver II
I used an entirely different measure, and it worked.
Here is the measure that I used.
ASA4 =VAR Duration = [ASA]VAR Minute_ = INT ( [ASA] )VAR Seconds =ROUNDUP( ([ASA] - Minute_ ) * 60 ,0)VAR M =IF (LEN ( Minute_ ) = 1,CONCATENATE ( "0", Minute_ ),CONCATENATE ( "", Minute_ ))VAR S =IF (LEN ( Seconds ) = 1,CONCATENATE ( "0", Seconds ),CONCATENATE ( "", Seconds ))"RETURN IF(NOT ISBLANK([ASA]),CONCATENATE ( M, CONCATENATE ( ":", S ) ) , "00:00")