cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Anonymous
Not applicable

AllExcept is messing up filter

Here is my scenario (simplified): 

 

I have a reference table: TableA

IDdescription
Athis is item A
Bthis is Item B
Cthis is Item C

 

 

And a detail table: TableB

Item IDCategoryQuantity
ABikes1
ABikes1
ACars1
BBikes1
BCars1
CCars1
CCars1

 

 

There is a one:many relationship between TableA->TableB on the item id.

Here is what I want:

  • first filter Table B by Category = "Cars",
  • but then add a measure that sums all of the quantities when Category = "Bikes"
  • include item description from TableA

I tried the following measure, and then adding description but it seems like calculate (or allexcept) is messing up filter context when I try to drag in "description" from TableA.

 

Bikes Quantity = CALCULATE(SUM(Table2[Quantity]), ALLEXCEPT(Table2, Table2[Item ID]), Table2[Category]="Bikes")

 

correct and incorrrect.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Impactful Individual
Impactful Individual

Re: AllExcept is messing up filter

Hi @Anonymous

 

You can get your measure to work as well. You just need a few filters on the category. They do it in a slightly different way but you can get to what you want.

 

measure4.PNG

View solution in original post

3 REPLIES 3
Highlighted
Impactful Individual
Impactful Individual

Re: AllExcept is messing up filter

you could try this

 

Bikes Quantity 1 = CALCULATE(SUM(TableB[Quantity]), filter(ALL(TableB),TableB[Item ID]=max(TableB[Item ID]) && TableB[Category]="Bikes"))

But you would need to include the Quantity column for it to show and it would be blank rather than 0 which isn't ideal.

 

measure1.PNG

 you could do it with a slightly different formula

 

Bikes Quantity 1 = if(ISBLANK( CALCULATE(SUM(TableB[Quantity]), filter(ALL(TableB),TableB[Item ID]=max(TableB[Item ID]) && TableB[Category]="Bikes"))),0, CALCULATE(SUM(TableB[Quantity]), filter(ALL(TableB),TableB[Item ID]=max(TableB[Item ID]) && TableB[Category]="Bikes")))

 Set category to be "First"

 

measure3.PNG

Highlighted
Anonymous
Not applicable

Re: AllExcept is messing up filter

@gooranga1Thanks for the query, seems to be working! Any chance you could go into some detail as to how this is working (what's actually happening?)

Highlighted
Impactful Individual
Impactful Individual

Re: AllExcept is messing up filter

Hi @Anonymous

 

You can get your measure to work as well. You just need a few filters on the category. They do it in a slightly different way but you can get to what you want.

 

measure4.PNG

View solution in original post

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Power Platform 2020 release wave 2 plan

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors