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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
ngc8164
Regular Visitor

Convert Duration to Hours and Minutes

In Power Query, how do I convert a duration to total hours & minutes.
For example 252.14:19:26.4230000 becomes 6062:19 and 42.07:02:28.9700000 becomes 1015:02

 

Many Thanks

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use this in a custom column

= Text.From(Number.IntegerDivide(Duration.TotalHours([Time]),1)) & ":" & Text.PadStart(Text.From(Number.Round(60*Number.Mod(Duration.TotalHours([Time]),1),0)),2,"0")

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI10jM0sTK0tDIy0zMxMjYAAqVYnWglEyM9A3MrAyMrIws9S3MDiHgsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type duration}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.From(Number.IntegerDivide(Duration.TotalHours([Time]),1)) & ":" & Text.PadStart(Text.From(Number.Round(60*Number.Mod(Duration.TotalHours([Time]),1),0)),2,"0"))
in
    #"Added Custom"

View solution in original post

2 REPLIES 2
ngc8164
Regular Visitor

Thanks very much Vijay. I made a slight adjustement to get exactly what I needed.

Vijay_A_Verma
Super User
Super User

Use this in a custom column

= Text.From(Number.IntegerDivide(Duration.TotalHours([Time]),1)) & ":" & Text.PadStart(Text.From(Number.Round(60*Number.Mod(Duration.TotalHours([Time]),1),0)),2,"0")

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjI10jM0sTK0tDIy0zMxMjYAAqVYnWglEyM9A3MrAyMrIws9S3MDiHgsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Time = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", type duration}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.From(Number.IntegerDivide(Duration.TotalHours([Time]),1)) & ":" & Text.PadStart(Text.From(Number.Round(60*Number.Mod(Duration.TotalHours([Time]),1),0)),2,"0"))
in
    #"Added Custom"

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors