Forum Discussion

ZusakheS's avatar
ZusakheS
New Member
3 years ago
Solved

Duration keeps changing to decimal after load

Why is it that data containing durations changes to a decimal after it is loaded into powerbi even though the data type is defined as duration in the transform stage. Is there a way to avoid this? Is...
  • v-yueyunzh-msft's avatar
    3 years ago

    Hi , ZusakheS 

    Based on my understanding and research on this product, currently there's no way to automatically to change the duration of time to the "Durtaion" format because there's no supported column format currently, you may try to create a measure as the workaround to achieve this duration in the time format like this:

     


    You can follow these steps to calcualte:

    1. Change the data type of duration column to HH:MM:SS:

     

    2. Create a calculate column to get the seconds:

    Second = SECOND('Table'[Duration])

     

    3. Create a measure to calculate the average seconds:

    Average =
    VAR _avg =
    AVERAGE ( 'Table'[Second] )
    VAR HoursPart =
    MOD ( INT ( _avg / 3600 ), 24 )
    VAR MinPart =
    MOD ( INT ( _avg / 60 ), 60 )
    VAR SecPart =
    MOD ( _avg, 60 )
    RETURN
    FORMAT (
    CONVERT ( HoursPart & ":" & MinPart & ":" & SecPart, DATETIME ),
    "hh:mm:ss"
    )

     

     

     

    Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

     

    Best Regards,

    Aniya Zhang

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