Forum Discussion

Millzy_moo796's avatar
Millzy_moo796
New Member
3 years ago
Solved

Converting decimals to MM:SS

Hi,

 

I'm completely stumpted and fustrated as to how I can achive this!

 

i'm trying to find out the average call waiting time, I have achieve this part... however the results are coming back as a decimal not and the time format how do I convert this back to time.

 

 

Thanks for any help!

 

  • Hi Millzy_moo796 

    Thanks for reaching out to us.

    please try this solution,  Solved: How to convert decimal to mm:ss in a Measure - Microsoft Power BI Community

    test 3 = 
    // Duration formatting 
    // * Given a number of seconds, returns a format of "hh:mm:ss"
    //
    // We start with a duration in number of minutes
    VAR Duration = [A]
    // Minutes is the integer part
    VAR Minutes =
        INT ( [A] )
    // Remaining seconds are the decimal remainder of the minutes times 60 after subtracting out the minutes
    VAR Seconds =
        ROUNDUP( ([A] - Minutes ) * 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 IF(Duration>0,
    CONCATENATE ( M, CONCATENATE ( ":", S ) ) , "00:00")

     

     

    Best Regards,

    Community Support Team _Tang

    If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

2 Replies