Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
pva
Frequent Visitor

Average calculation

Hi all! I want to calculate an average this way

 

I have this table:

 

 

CodePeriodHours
51252019022
51252019034
51252019036
51252019043
51252019054

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!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

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 :

Ailsamsft_0-1644478277662.png

 

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.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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 :

Ailsamsft_0-1644478277662.png

 

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.

parry2k
Super User
Super User

@pva try this measure

 

Avg = 
AVERAGEX ( VALUES ( Table[Period] ), CALCULATE ( AVERGAGE ( Table[Hours] ) ) )

 

 

Follow us on LinkedIn and YouTube.gif 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.



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.

pva
Frequent Visitor

Thank for your help. In the table there are more codes. The table would be like this:

CodePeriodHours
51252019022
51252019034
51252019036
51252019043
51252019054
21472019022
21472019024
21472019038
21472019043

 

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.