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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
water-guy-5
Helper III
Helper III

Find average of all values in a column (example tables and outputs included)

I'm a little rusty with Power BI so please forgive me.

I have a table with a sales column that looks like this. Let's call it 'Table1'
Location          Sales
A                      500
B                      1000
C                      750
D                      250
E                       1500

I have added a datacard that just calculates the average using the dropdown in the fields pane. Simple enough, right?

When I make a table visual, what I want is a calculate column or measure that shows the average for all locations. So, since the average across all (and the value in my datacard) is 800, I want the output to be this

Location          Sales            Organization Average
A                      500                       800
B                      1000                      800
C                      750                        800
D                      250                       800
E                       1500                       800

 

That way, I can create a rankx column and rank the locations. I understand that I can just sort the column, but I will be applying this logic to about 5 different areas and want to create a scoring system. I know I have to use ALLSELECTED or ALL but for some reason this is giving me a hard time. Any help would be appreciated, thanks!

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @water-guy-5 

According to your description, you want to get the average of the Location.

Here are the steps you can refer to :
[1]If you want to add a calculated column , you can click "New Column" and enter this:

Average Column = AVERAGEX('Table',CALCULATE(SUM('Table'[Sales]) ,ALLEXCEPT('Table','Table'[Location])))

The result is as follows:

vyueyunzhmsft_0-1674181604005.png

[2]If you want to create a measure you can click "New measure" and enter this:

Average = AVERAGEX( ALLSELECTED('Table'[Location]) , CALCULATE(SUM('Table'[Sales])))

 

The result is as follows:

vyueyunzhmsft_1-1674181643676.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

To be able to rank the locations, you do not need to create a column with those averages.  Try these measures:

Total = sum(Data[Sales])

Rank = rankx(allselected(Data[Locations]),[Total])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yueyunzh-msft
Community Support
Community Support

Hi , @water-guy-5 

According to your description, you want to get the average of the Location.

Here are the steps you can refer to :
[1]If you want to add a calculated column , you can click "New Column" and enter this:

Average Column = AVERAGEX('Table',CALCULATE(SUM('Table'[Sales]) ,ALLEXCEPT('Table','Table'[Location])))

The result is as follows:

vyueyunzhmsft_0-1674181604005.png

[2]If you want to create a measure you can click "New measure" and enter this:

Average = AVERAGEX( ALLSELECTED('Table'[Location]) , CALCULATE(SUM('Table'[Sales])))

 

The result is as follows:

vyueyunzhmsft_1-1674181643676.png

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.