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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
cottrera
Post Prodigy
Post Prodigy

Convert time (hh:mm) to decimal

Hi

I have the following table

 

Time ReceivedTime Decimal
09:519.85
09:409.67
09:449.73
18:3718.62
16:0416.07
16:2816.47
01:301.50
08:328.53
09:349.57
12:1412.23
08:318.52
08:258.42
06:136.22
19:1119.18
10:4410.73
18:2118.35
11:1411.23

 

I wish to convert  the time field (hh:mm) into decimal.

 

thank you

 

Richard

 

1 ACCEPTED SOLUTION

nonono, you don't want to add column to column. In addition to that your [Time Received] is not text but of "time" type. That's smth new to me. Replace your "lady in red" with this:

#"Added Custom" = Table.AddColumn(#"Inserted Hour", "Time Decimal", each [a = Time.ToRecord([Time Received]), b = Number.Round(a[Hour] + a[Minute] / 60, 2)][b])

 

View solution in original post

6 REPLIES 6
cottrera
Post Prodigy
Post Prodigy

Thats got it thank you for your patience , legend 😀

cottrera
Post Prodigy
Post Prodigy

Hi AlienSx

I have added your code to my other code via the advanced editor.

 

let
Source = Exchange.Contents("xxxxxxxxxxxxxxxxxxx"),
Mail1 = Source{[Name="Mail"]}[Data],
#"Duplicated Column" = Table.DuplicateColumn(Mail1, "DateTimeReceived", "DateTimeReceived - Copy"),
#"Changed Type" = Table.TransformColumnTypes(#"Duplicated Column",{{"DateTimeReceived - Copy", type time}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"DateTimeReceived - Copy", "Time Received"}}),
#"Duplicated Column1" = Table.DuplicateColumn(#"Renamed Columns", "DateTimeReceived", "DateTimeReceived - Copy"),
#"Extracted Day Name" = Table.TransformColumns(#"Duplicated Column1", {{"DateTimeReceived - Copy", each Date.DayOfWeekName(_), type text}}),
#"Renamed Columns1" = Table.RenameColumns(#"Extracted Day Name",{{"DateTimeReceived - Copy", "Day"}}),
#"Inserted Hour" = Table.AddColumn(#"Renamed Columns1", "Hour", each Time.Hour([Time Received]), Int64.Type),
#"Added Custom" = Table.AddColumn(#"Inserted Hour", "Custom", each Table.AddColumn(Source, "Time Decimal", each [a = Time.ToRecord(Time.FromText([Time Received])), b = Number.Round(a[Hour] + a[Minute] / 60, 2)][b]))
in
#"Added Custom"


However, when I tried to expand the table

cottrera_1-1684409690036.png

 

 

I receive this message

cottrera_3-1684409747225.png

Richard

 

 

nonono, you don't want to add column to column. In addition to that your [Time Received] is not text but of "time" type. That's smth new to me. Replace your "lady in red" with this:

#"Added Custom" = Table.AddColumn(#"Inserted Hour", "Time Decimal", each [a = Time.ToRecord([Time Received]), b = Number.Round(a[Hour] + a[Minute] / 60, 2)][b])

 

AlienSx
Super User
Super User

hi, @cottrera 

[a = Time.ToRecord(Time.FromText([Time Received])), b = a[Hour] + a[Minute] / 60][b]

Hi AlienSx thankyou for responding so quickly. Im not sure I fully understadn  how to apply this logic in Power Query. Could you please expand RIchard

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("TY3BDcAgDAN34d1HnAQKXgWx/xpUBFB/J/uc9J6kMSONZ5HLJV+ESnuDCsUPaQ0PtL34PD1b254Sflsc0hxUCAuvEdFCfn91Z1hXxgQ=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Time Received" = _t]),
    #"Added Custom" = Table.AddColumn(Source, "Time Decimal", each [a = Time.ToRecord(Time.FromText([Time Received])), b = Number.Round(a[Hour] + a[Minute] / 60, 2)][b])
in
    #"Added Custom"

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors