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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Feb2025 NL Carousel

Fabric Community Update - February 2025

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