Forum Discussion
Remove seconds from time in Power Query Editor
- 7 years ago
I punted on trying to change the format of the time column.
I changed my time dimension table to use seconds as the smallest grain. Doing that and then relating it to the time column in my source table did the trick.
This is where I found code for a time dimension table:
https://ginameronek.com/2014/10/01/its-just-a-matter-of-time-power-bi-date-time-dimension-toolkit/
I changed
Source = List.Times(#time(0, 0, 0),MinuteCount, #duration(0,0,1,0)),
to
Source = List.Times(#time(0, 0, 0),86400, #duration(0,0,0,1)),
to get a seconds grain.
Works fine, no noticible lag in performance.
I'm doint this in Power BI, and I'm afraid I don't know how to run that code. I tried something like that where I split the column into hours and minutes, but when I merged them it didn't add the zeros to the minutes, leaving this:
2:05 --> 2:5
Does your code deal with this? And how can I run it from Power BI?
I'll have to look at the single digit issue. To run the code, open up Power Query Editor. Create a new blank query. While in that query, select Advanced Editor from the ribbon. Use Ctrl+A to select all of the existing code and paste in the code that I have replacing all of the existing code. Close out of the Advanced Editor.
- bgibb7 years agoAdvocate II
I see now - I can run your code. If there is a way to add a single digit minute to the test data that would help me out.
Thank you so much for dealing with a newbie. This is so different from all the other languages and platforms I have experience with...
- bgibb7 years agoAdvocate II
I punted on trying to change the format of the time column.
I changed my time dimension table to use seconds as the smallest grain. Doing that and then relating it to the time column in my source table did the trick.
This is where I found code for a time dimension table:
https://ginameronek.com/2014/10/01/its-just-a-matter-of-time-power-bi-date-time-dimension-toolkit/
I changed
Source = List.Times(#time(0, 0, 0),MinuteCount, #duration(0,0,1,0)),
to
Source = List.Times(#time(0, 0, 0),86400, #duration(0,0,0,1)),
to get a seconds grain.
Works fine, no noticible lag in performance.