Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi all! I want to calculate an average this way
I have this table:
| Code | Period | Hours |
| 5125 | 201902 | 2 |
| 5125 | 201903 | 4 |
| 5125 | 201903 | 6 |
| 5125 | 201904 | 3 |
| 5125 | 201905 | 4 |
So, if I calculate it with the average function the calculation would be like this:
(2+4+6+3+4)/5 = 3,8
But I don't want this way of calculating it. The way I want is, first, calculating the average per period and finally calculating the average of those averages. Example:
Avg 2019/02 = 2
Avg 2019/03 = 5
Avg 2019/04 = 3
Avg 2019/04 = 4
So the final average would be 4,25 -> (2+5+3+4)/4
Any idea of how to solve it?
Thank you all!!
Solved! Go to Solution.
Hi @pva
How did you get 4.5 when you use (2+5+3+4)/4 ? The correct answer is 3.5 .
For 5125 , the final result is 3.5 -> ((4+6)/2+2+3+4)/4 .For 2147 , the final result is 4.667 -> ((2+4)/2+8+3)/3 . So the final average is 4.08 ->(3.5+4.667)/2
To realize the final average , you need to nest an AVERAGEX() outside the formula provided by SU .
Avg =AVERAGEX(VALUES('Table'[Code]),calculate(AVERAGEX(VALUES('Table'[Period]),CALCULATE(AVERAGE('Table'[Hours])))))
The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @pva
How did you get 4.5 when you use (2+5+3+4)/4 ? The correct answer is 3.5 .
For 5125 , the final result is 3.5 -> ((4+6)/2+2+3+4)/4 .For 2147 , the final result is 4.667 -> ((2+4)/2+8+3)/3 . So the final average is 4.08 ->(3.5+4.667)/2
To realize the final average , you need to nest an AVERAGEX() outside the formula provided by SU .
Avg =AVERAGEX(VALUES('Table'[Code]),calculate(AVERAGEX(VALUES('Table'[Period]),CALCULATE(AVERAGE('Table'[Hours])))))
The final result is as shown :
I have attached my pbix file , you can refer to it .
Best Regard
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@pva try this measure
Avg =
AVERAGEX ( VALUES ( Table[Period] ), CALCULATE ( AVERGAGE ( Table[Hours] ) ) )
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Thank for your help. In the table there are more codes. The table would be like this:
| Code | Period | Hours |
| 5125 | 201902 | 2 |
| 5125 | 201903 | 4 |
| 5125 | 201903 | 6 |
| 5125 | 201904 | 3 |
| 5125 | 201905 | 4 |
| 2147 | 201902 | 2 |
| 2147 | 201902 | 4 |
| 2147 | 201903 | 8 |
| 2147 | 201904 | 3 |
So the global average should be:
5125 -> 4,25
2147 -> 3,66 (2+((4+8)/2)+3)/3
Total avg = (4,25+3,66)/2 = 3,955
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 39 | |
| 38 | |
| 38 | |
| 28 | |
| 27 |
| User | Count |
|---|---|
| 124 | |
| 88 | |
| 73 | |
| 66 | |
| 65 |