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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
BlastS
Helper I
Helper I

Convert from duration 10 to DateTime

How can i convert this column to DateTIme, 

SUM.png

I have values like 20 30 50 and when i am sum them it will be for example 140 and would like this convert to 00:02:20:00 (0 days 2 hours 20 min 0 seconds)

 

Input : 200

Output should be for example: 00:03:20:00

 

How can i achieve this on powerbi? 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Generally DateTime values are expressed as decimal figures, where 1 hour is 1/24  (i.e. 0.04166666667).

 

Here is some sample Query code that does what I'm talking about:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjJQitWJVjKGUKZAKhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Time = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "AsTime", each [Time] / 24 / 60),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"AsTime", type duration}})
in
    #"Changed Type1"

The Source row is just "Enter Data" where i've put a value in (20, 30 and 50) to give your minutes as a whole number.

Next we create a new column which converts Whole Number minutes into the DateTime I mentioned earlier (divide 24, divide 60).

Then I convert the datatype to "duration" which will show each of those times as "0.00:20:00" and so on.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Generally DateTime values are expressed as decimal figures, where 1 hour is 1/24  (i.e. 0.04166666667).

 

Here is some sample Query code that does what I'm talking about:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjJQitWJVjKGUKZAKhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Time = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "AsTime", each [Time] / 24 / 60),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"AsTime", type duration}})
in
    #"Changed Type1"

The Source row is just "Enter Data" where i've put a value in (20, 30 and 50) to give your minutes as a whole number.

Next we create a new column which converts Whole Number minutes into the DateTime I mentioned earlier (divide 24, divide 60).

Then I convert the datatype to "duration" which will show each of those times as "0.00:20:00" and so on.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors