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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Calculate average considering all columns except one

Hi Team,

 

I have a Table matrix with 5 columns added in it and "State" is one of the column.  

 

I want to get the average sales at the national level, i.e, that measure should ignore filter from "State".

 

Is the below DAX correct?

 

Avg National = CALCULATE(AVERAGE(Query1[Sale]),ALL(Query1[State]))
1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try to use allexcept and add 'country' and 'Speciality' to the filter condition.

Measure = CALCULATE(AVERAGE('Table'[sale]),ALLEXCEPT('Table','Table'[Speciality],'Table'[country]))

 

Best Regards,
Liang
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

6 REPLIES 6
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try to use allexcept and add 'country' and 'Speciality' to the filter condition.

Measure = CALCULATE(AVERAGE('Table'[sale]),ALLEXCEPT('Table','Table'[Speciality],'Table'[country]))

 

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

amitchandak
Super User
Super User

@Anonymous , try like

 

Avg National = CALCULATE(AVERAGE(Query1[Sale]),removefilters(Query1[State]))

or

Avg National = CALCULATE(AVERAGE(Query1[Sale]),all(Query1))

or

Avg National = CALCULATE(AVERAGE(Query1[Sale]),allexcept(Query1,Query1[Country]))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Super User
Super User

@Anonymous Try ALLEXCEPT to remove filters on everything except particular columns or REMOVEFILTERS. Your code is correct if you are trying to ignore filters on State column

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Hi Greg,

Below is how my table looks like. In the Average - National level, I except only 2 values, one for Rap and one for Classic. But currently its not giving me the expected result.

how can i modify my DAX to get the correct value?

DivisionAssignment TypeSpecialityStateAverage -State levelAverage- National level
NorthTransRapCalifornia$83.09$83.09
NorthTransRapFlorida$68.60$68.60
NorthTransRapIllinois$82.80$82.80
NorthTransRapMissouri$65.00$65.00
NorthTransClassicCalifornia$87.20$87.20
NorthTransClassicFlorida$75.46$75.46
NorthTransClassicMissouri$88.00$88.00

@Anonymous What is your expected result?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler For Rap, i should be getting 77.28 in all 4 & for Classic it should be 80.06.

 

Basically, i need a national level average.

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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