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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
rmeng
Helper II
Helper II

ALLEXCEPT function to preserve a filter on a given column

I need a formula that gives me the result like the pivot tables:

  • The dataset has several dimensions and if you look in the pictures Argentina could belong  to 2 different regions (many to many relationship).
  • So when I choose either Latam or BIR the result shoulb be the same 63.
  • I´ve created this # Attendees = CALCULATE(MAX(Attendees[#Attendees]);ALLEXCEPT(Attendees;Attendees[AttendeeIdentifier])),  but in the end the value is 80!

example 2.png

 

example 1.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

You need something like this:

[# Attendees] =
	SUMX(
		VALUES( Attendees[AttendeeIdentifier] ),
		CALCULATE(
			MAX( Attendees[#Attendees] )
		)
	)

even though... when I look at the first visual, it looks like you are also taking into consideration the region since the total is 126. The measure above will not give you 126, it'll return 63. However, if you change the measure so that it does return 126 for this visual... it'll not return 63 for the second visual. It'll return 126.

 

So, in a word, it looks like either your defnition is not consistent or... you want 1 measure to behave differently depending on whether there is a filter on region or not. However, please note that while the individual cells in a table can have a filter on region, the totals won't (for the majority of cases) and hance you won't be able to do what you want to do according to what your visuals show.

 

Best

D

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

You need something like this:

[# Attendees] =
	SUMX(
		VALUES( Attendees[AttendeeIdentifier] ),
		CALCULATE(
			MAX( Attendees[#Attendees] )
		)
	)

even though... when I look at the first visual, it looks like you are also taking into consideration the region since the total is 126. The measure above will not give you 126, it'll return 63. However, if you change the measure so that it does return 126 for this visual... it'll not return 63 for the second visual. It'll return 126.

 

So, in a word, it looks like either your defnition is not consistent or... you want 1 measure to behave differently depending on whether there is a filter on region or not. However, please note that while the individual cells in a table can have a filter on region, the totals won't (for the majority of cases) and hance you won't be able to do what you want to do according to what your visuals show.

 

Best

D

harshnathani
Community Champion
Community Champion

HI @rmeng ,

 

Instead of MAX, try using SUM.

 

This should give you the answer.

 

Regards,

Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!!

Greg_Deckler
Community Champion
Community Champion

This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376

Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907



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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

What I want is formula when I filter by Country that returns the max [#Attendee] of AAA ([attendeeidenfier]).

So in this case Argentina only have 1 Attendee instead of 2 for the first two rows.

Te total shoulb be When I filter by Argentina = 63 when I filter by LATAM = 63 and BIR = 63.

PS: I have multiple other dimensios in this table

example 3.png

 

Anonymous
Not applicable

To get the right number, you have to create the measure using SUMX and iterate through the identifiers in the current context getting the common value of the # Attendees field for the identifier. Then and only then will you get the number you want.

Best
D

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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