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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Jeanxyz
Post Prodigy
Post Prodigy

why relationship didn't propagate with allexcept()

According to the defintion of allexcept(), this formula removes all the filters except the column specified in the formula. 

 

My questions is if the filter is retained in a specific column, shouldn't relationship propagation continue to work for that column?

 

In my data model, I have a product category table which is linked to sales table. I then write a measure which sums up sales amount ignoring any  filter context unless there is a filter on product category. When I call this measure in a pivot table which uses Product Category[product category] in the row, it looks relationship didn't get propagated. It gives the same results despite the product category context.  

 

sales of all except category2 = calculate(sum(sales[sales amount]),allexcept('sales','sales'[product category]))
 
Why allexcept() doesn't take external filter context (i.e., pivot table)?  Don't calculate() always copy external filter context to the new filter context? 
 
 
allexcept.PNG
1 ACCEPTED SOLUTION
bcdobbs
Super User
Super User

Hi,
In your model the table Product Category is on the one side of the one to many relationship with Sales.

 

All of the columns of Product Category therefore exist in the expanded table version of Sales (Expanded tables in DAX - SQLBI). 

 

ALLEXCEPT when used as a calculate modifer removes all filters from the entire expanded table of sales apart from the specified column. ALLEXCEPT – DAX Guide

 

In the measure that doesn't work the matrix is adding 'Product Category'[product category] into the filter context but ALLEXCEPT is then removing it because it's in the expanded table. 


I generally try to avoid ALLEXCEPT as a calculate modifer as it's very easy to write code that breaks easily. You're better in general using a REMOVEFILTERS, VALUES pattern explained in Using ALLEXCEPT versus ALL and VALUES - SQLBI



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

View solution in original post

4 REPLIES 4
bcdobbs
Super User
Super User

Hi,
In your model the table Product Category is on the one side of the one to many relationship with Sales.

 

All of the columns of Product Category therefore exist in the expanded table version of Sales (Expanded tables in DAX - SQLBI). 

 

ALLEXCEPT when used as a calculate modifer removes all filters from the entire expanded table of sales apart from the specified column. ALLEXCEPT – DAX Guide

 

In the measure that doesn't work the matrix is adding 'Product Category'[product category] into the filter context but ALLEXCEPT is then removing it because it's in the expanded table. 


I generally try to avoid ALLEXCEPT as a calculate modifer as it's very easy to write code that breaks easily. You're better in general using a REMOVEFILTERS, VALUES pattern explained in Using ALLEXCEPT versus ALL and VALUES - SQLBI



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!

Hi Ben

But why if i put product category from sales table , then this measure will work 

as i know filters propagate from 1 to many , am not getting the concept that if i take the product category from product table, the filter should also propagate to the many section even if i have allexcept , its a bit confusing

Have a read of this article:

https://www.sqlbi.com/articles/expanded-tables-in-dax/

The whole thing, but real focus on the section on filter propegation. Let me know if that helps or not.



Ben Dobbs

LinkedIn | Twitter | Blog

Did I answer your question? Mark my post as a solution! This will help others on the forum!
Appreciate your Kudos!!
parry2k
Super User
Super User

@Jeanxyz you will do this 

 

sales of all except category2 = calculate(sum(sales[sales amount]),allexcept('sales','Product Category'[product category]))

 

Follow us on LinkedIn

 

Learn about conditional formatting at Microsoft Reactor

My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

 

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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