How to deal with milliseconds in PowerBI

梦想的初衷 提交于 2019-12-11 15:27:51

问题


I am working with a bot, and I need to sort the event by a datetime column, when I import the column from my database I have this format:

2017-10-19T14:26:57.2349278Z

after importing in power BI and changing the data type to date time I get this:

10/19/2017 02:26:57 PM

all the trailing milliseconds are truncated, but I need them to sort correctly the events, because some events occurs in the same second.

Any body any idea? Thanks!


回答1:


Starting with a sample table of dates in your format, when loaded into Power BI, this is the result.

Click on the Navigation step and then click on Add Column -> Custom Column. A prompt will pop up asking if you want to insert a step, click Insert.

In the prompt, enter the following formula.

Text.Start([#"Timestamp"], 4) & 
Text.Middle([#"Timestamp"], 5, 2) & 
Text.Middle([#"Timestamp"], 8, 2) & 
Text.Middle([#"Timestamp"], 11, 2) & 
Text.Middle([#"Timestamp"], 14, 2) & 
Text.Middle([#"Timestamp"], 17, 2) & 
Text.Middle([#"Timestamp"], 20, 7)

This gives you a column that can be used to sort the items in the table by a precise datetime. Note that the custom column formula requires the raw date string to be in the exact same format as in your question.



来源:https://stackoverflow.com/questions/46833631/how-to-deal-with-milliseconds-in-powerbi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!