Forum Discussion
how to get the index value in the string/datetime
Try using Duration.TotalMinutes to convert to total minutes.
To directly answer your question, you can use Duration.Hours to get the number of hours to multiply by 60, but this approach takes more steps than directly converting to minutes as I suggested above.
- harryli4 years ago
Helper II
Thanks for the reply, I know this method, but I am using "DirectQuery" mode. After I import the Duration function, the system show "switch to import mode". Therefore, I have to find the transfer method in "DirectQuery" mode. Anyway, thanks for the help.
- AlexisOlson4 years ago
Super User
Power BI interprets time in units of days, so you might be able to just multiply by the number of minutes in a day (24 hr/day * 60 min/hr = 1440 min/day).
I'm not sure if the conversion to decimal will fold but it's worth a try.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjCwMjWxMjTUMzI2MFGK1QGKGFoZGVkZmEJFYgE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [current = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"current", type time}}), ToDecimal = Table.TransformColumnTypes(#"Changed Type",{{"current", type number}}), #"Added Custom" = Table.AddColumn(ToDecimal, "Minutes", each [current]*24*60, type number) in #"Added Custom"- harryli3 years ago
Helper II
if changes the datatype will not available to DirectQuery mode.