Forum Discussion
Calculate Time over multiple months
- 6 years ago
Its not that simple 🙂
You can do it in number of steps.
- Change your time column to text format. So it will look like normal time format but its text 00:04:00
- Split by delimiter :
- You will have 3 columns (One for HOURS, second is MINUTES and third is SECONDS) change type to WHOLE NUMBER
- From Add Column tab select CUSTOM COLUMN, name this column CustomH
- HOURS * 3600 (thats number of seconds in one hour)
- From Add Column tab select CUSTOM COLUMN, name this column CustomM
- MINUTES * 60 (number of seconds in one minute)
- From Add Column tab select CUSTOM COLUMN, name this column TimeInSeconds
- CustomH + CustomM + SECONDS
- Close & Apply
Now you converted your time into seconds =D
Then create new measure and copy and paste my logic but just use your table name and column name.
Hope it clear now.
Abduvali
Hello Abduvali,
With such a fast reply, I'm sure you are onto the correct solution for me. However, I'm not quite sure what to do with all this code.
Any chance you could be alittle more specific on what I need to do inside Power BI Desktop, to use the solution?
When going into the Query and clicking "Custom Column" it gives me a box with "=" as the only text in it, then copy pasting this:
But it gives me an error in the window.
Thanks in advance for your support, it's much appreciated.
No, the code is for a MEASURE.
In Edit Query mode find your time column and convert it to secods!
Do you know how to achieve the following???
If yes, then just use that TimeInSeconds column in the code provided below: (this code you will use to create NEW MEASURE in the report view)
Avg Time =
- Bassehave6 years agoHelper I
Hello Abduvali,
I have removed all of my old formatting to start from the beginning.
Now I converted my time column into the "time" format. I don't see anywhere to convert it to seconds? Under "Date & Time Column" I can choose Seconds, but that only extracts seconds from the time.
Am I missing something here?
- Abduvali6 years agoSkilled Sharer
Its not that simple 🙂
You can do it in number of steps.
- Change your time column to text format. So it will look like normal time format but its text 00:04:00
- Split by delimiter :
- You will have 3 columns (One for HOURS, second is MINUTES and third is SECONDS) change type to WHOLE NUMBER
- From Add Column tab select CUSTOM COLUMN, name this column CustomH
- HOURS * 3600 (thats number of seconds in one hour)
- From Add Column tab select CUSTOM COLUMN, name this column CustomM
- MINUTES * 60 (number of seconds in one minute)
- From Add Column tab select CUSTOM COLUMN, name this column TimeInSeconds
- CustomH + CustomM + SECONDS
- Close & Apply
Now you converted your time into seconds =D
Then create new measure and copy and paste my logic but just use your table name and column name.
Hope it clear now.
Abduvali
- Bassehave6 years agoHelper I
Thanks a lot for the clarification!
I will stop looking for the one-button-does-all 🙂
And again, thanks a lot for your support, I have marked the reply as a solution 🙂
- Greg_Deckler6 years agoCommunity Champion
OK, it is for a measure, can still do Custom Formatting for a measure using the article I referenced. I'm not sure why that makes a difference.