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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.