Forum Discussion
Average calculation
- Anonymous4 years ago
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] ) ) )
✨ Follow us on LinkedIn and to our YouTube channel
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.
- pva4 years agoFrequent Visitor
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