Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello everyone,
I'm having an issue getting an average of time over multiple months. Let me give an example. I'm converting Time to Decimal to be able to multiply with Calls.
Date | Calls | Time | Converted | Total |
Day 1 | 100 | 00:04:00 | 0,00277777777777778 | 100 * 0,00277777777777778 = 0,277778 |
Day 2 | 5 | 00:20:00 | 0,0138888888888889 | 5 * 0,0138888888888889 = 0,069444 |
Total | 105 | 0,277778 + 0,069444 = 0,347222 |
And the final calculation is: 0,347222 / 105 = 0,003307. If I convert 0,003307 to Time the result is: 00:04:46
If I simply took the average of the two Times, I would get 00:12:00 instead, which is wrong.
I created a measure [Calls] where I summed the whole Calls column. I did the same for Time (after converting to Decimal). If I pull the sum of Time into the report I get the correct decimal number, but when trying to do the measure [Time] / [Calls] the result is totally wrong. Also when I pulled the [Time] measure into the report, I'm not able to convert that decimal number back into a time format.
Do any of you know how to do a proper time calculation in Power BI?
Thanks in advance,
Solved! Go to Solution.
Its not that simple 🙂
You can do it in number of steps.
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
See if this helps: https://community.powerbi.com/t5/Quick-Measures-Gallery/Chelsie-Eiden-s-Duration/m-p/793639#M389
Hi @Bassehave ,
Just create new column and convert you time into seconds and use it to calculate your average time.
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 =
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.
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?
Its not that simple 🙂
You can do it in number of steps.
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
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 🙂
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
114 | |
99 | |
82 | |
70 | |
60 |
User | Count |
---|---|
149 | |
114 | |
107 | |
89 | |
67 |