Forum Discussion
Show milliseconds from data source with Power Query
Thanks for the suggestion. But Time.From([Timestamp]) yields the same result - it displays without the milliseconds and I'm trying to get it to display in the power query cells with milliseconds. Ultimately I'll be doing math with those milliseconds.
I think you are presenting an XY problem.
Doing the math has nothing to do with the format you see in the Power Query cell. Using the duration type will allow you to see the milliseconds. Using the time type will not. But in either case, the milliseconds will be preserved in the value stored, so there should be no problem doing math.
If you need to see it exactly as you show for some reason, then give it a text type and just use the appropriate conversion functions when you do the math.
- slcekala772 years agoNew Member
Thanks for the reply. I do understand that the values will be preserved in the data. I'm trying to get all the way through PQ before dabbling in PowerBI, so I'll keep in mind that this is possible in PowerBI and look at that sooner than I otherwise might have. I'll also take a closer look at the duration type.
I'm transitioning this data from a in-worksheet dataset where one of the things I'm computing is the difference in milliseconds between rows to identify those records where the difference is over (for example) 2 milliseconds. But I'm having trouble understanding what to do where and I may be too focused on what it looks like in PQ for the moment 🙂
- ronrsnfld2 years agoSuper User
Here's an example showing the difference in milliseconds between two values, and also demonstrating that even with the time type, the result is proper. You could also use the duration type, but both columns should be the same data type.
let Source = #table(type table[Time1=text, Time2=text],{{"19:56:40.0560000", "19:56:40.0920000"}}), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Time1", type time}, {"Time2", type duration}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Milliseconds Difference", each Duration.Seconds([Time2]-[Time1])*1000, type number) in #"Added Custom"If you want to leave the data as text type, then you could use the following to get the difference:
let Source = #table(type table[Time1=text, Time2=text],{{"19:56:40.0560000", "19:56:40.0920000"}}), #"Added Custom" = Table.AddColumn(Source, "Milliseconds difference", each Duration.Seconds(Time.From([Time2])- Time.From([Time1])) *1000, type number) in #"Added Custom"