Forum Discussion
Anonymous
3 years agoNot applicable
How to show hour difference with decimals
Hello, I have a table in which I calculated the hour difference with the following syntax: Duration.Hours(Hour #1 - Hour #2). I get the results correctly for the integer but I can't add the decimals....
adudani
Memorable Member
3 years agohi Anonymous ,
create a blank query and copy and paste the code below:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTI0sjIwgNCmpiBmbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [task = _t, hour1 = _t, hour2 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"task", Int64.Type}, {"hour1", type time}, {"hour2", type time}}),
#"Inserted Time Subtraction" = Table.AddColumn(#"Changed Type", "Subtraction", each [hour1] - [hour2], type duration)
in
#"Inserted Time Subtraction"
is this the desired output?
if hour 1> hour 2, would you prefer returning a 0 instead of a negative value?