Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Change decimal to duration

I have a column in a table called duration which is in decimal format, for example, 34.60 but I need to change that to mm:ss format so instead it should be 34minutes 36 seconds , or 34:36. 

 

How would I be able to do this? 

  • Also, If you want to do it in Power Query, change the type of your column to Text(or create the new one as text) and then create the new column as a below :

    Text.BeforeDelimiter( [Duration],".") & ":" & Number.ToText( Number.FromText( Text.AfterDelimiter( [Duration],".")) *6)

7 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      Power Query is fine, but what is the DAX Solution?

      • Dinesh_Suranga's avatar
        Dinesh_Suranga
        Icon for Continued Contributor rankContinued Contributor

        Anonymous ,

        Hi,

        You can try following code to create new column in power query.

        = Text.BeforeDelimiter( [Duration],".") & ":" & Number.ToText( Number.FromText( Text.AfterDelimiter( [Duration],".")) *0.6)

         Thank you.

  • MahyarTF's avatar
    MahyarTF
    Icon for Memorable Member rankMemorable Member

    Hi,

    Create the column as below : 

    Time = time(0,
                hour(FORMAT(TIME(TRUNC(Sheet229[Duration],0),(Sheet229[Duration]-TRUNC(Sheet229[Duration],0))*60,0),"long time")),
                minute(FORMAT(TIME(TRUNC(Sheet229[Duration],0),(Sheet229[Duration]-TRUNC(Sheet229[Duration],0))*60,0),"short time"))
            )
    ******** Sheet229[Duration] is my decimal column
    Appreciate your Kudos
    Please mark it as solution if it helps 
    • MahyarTF's avatar
      MahyarTF
      Icon for Memorable Member rankMemorable Member

      Also, If you want to do it in Power Query, change the type of your column to Text(or create the new one as text) and then create the new column as a below :

      Text.BeforeDelimiter( [Duration],".") & ":" & Number.ToText( Number.FromText( Text.AfterDelimiter( [Duration],".")) *6)