cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
harryli
Helper II
Helper II

how to get the index value in the string/datetime

harryli_0-1662710526862.png

As the above data is one DateTime value minus another DateTime value which is the DirectQuery mode.

Now, I would like to transfer it to be only minutes value, but there is a situation like the following example:

0.01:22 means 1h22mins

return: 82 mins.

Therefore, I want to know how to get the index value to multiple 60 mins.

6 REPLIES 6
AlexisOlson
Super User
Super User

Try using Duration.TotalMinutes to convert to total minutes.

AlexisOlson_0-1662762273468.png

 

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.

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.

harryli_0-1663057747389.png

 

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"

AlexisOlson_0-1663098893445.png

if changes the datatype will not available to DirectQuery mode.

I mean your [current] column.

serpiva64
Super User
Super User

Hi,

excuse me but i can't clearly understand what you need.

Can you post another exemple of the result you need?

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors