Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Try your skills in the Power BI Dataviz World Championship! Round one ends June 26. Join now

Reply
Anonymous
Not applicable

duration format

Hello, I have a duration column in Power query, but it transforms in decimals when I go to the data panel. When I do an average, it is all in decimals. I want to be able to show the average in a time format: 00:00:43 (43 secondes). I searched everywhere on the web and there is no solution. Thank you

 

 

guillaume_boism_0-1636477010824.png

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can follow these steps to calcualte:

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

vyingjl_0-1636695884171.png

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"
    )

vyingjl_1-1636695975395.png

 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can follow these steps to calcualte:

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

vyingjl_0-1636695884171.png

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"
    )

vyingjl_1-1636695975395.png

 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

What if i need to calculate the Duration in Minutes, Hours or all together?

amitchandak
Super User
Super User

@Anonymous , You need to take avg in decimal and convert it back to duration for display

 

example

quotient(Seconds1,3600 ) & ":" & FORMAT ( quotient(mod(Seconds1,3600 ),60), "00" ) & ":" & FORMAT ( mod(mod(Seconds1,3600 ),60), "00" )

 

 

refer if these solution can help

https://radacad.com/calculate-duration-in-days-hours-minutes-and-seconds-dynamically-in-power-bi-usi...
https://social.technet.microsoft.com/wiki/contents/articles/33644.powerbi-aggregating-durationtime-i...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.