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
RedPeppery
Frequent Visitor

Skip context apply by matrix visuals columns but keep context from above - allselected not working

Hello, 

 

I need to avoid the filter context apllied by the columns of a matrix in order to calculate the total for the full year instead just one month for a particular product. 

 

I have a month table that has a many to one relation with a date table that has a many to one relation with a fact table. 

Then I have a product table that is link to the fact table as well. 

 

The formula that I use is this: CALCULATE([Sold],filter(Product,Product[Index]=7),ALLSELECTED(DatesKeyMonths[Month]))

sold is a countrows of factTable

The result should be 2, instead of one, 1 product was sold each month

 

RedPeppery_1-1677586149500.png

RedPeppery_2-1677586242349.png

RedPeppery_0-1677586036440.png

1 ACCEPTED SOLUTION
MAwwad
Solution Sage
Solution Sage

 

Based on your explanation, it sounds like you want to ignore the filter context applied by the columns of a matrix visual while still keeping the context from the rows above. To achieve this, you can use the ALLEXCEPT function to remove the filter context for all columns except for the DatesKeyMonths[Month] column, which will be preserved by the ALLSELECTED function.

Here's the modified formula:

 

 
CALCULATE( [Sold], FILTER( Product, Product[Index] = 7 ), ALLEXCEPT( DatesKeyMonths, DatesKeyMonths[Month] ), ALLSELECTED(DatesKeyMonths[Month]) )
 

This formula uses the FILTER function to filter the Product table for the product with an index of 7. The ALLEXCEPT function is then used to remove the filter context for all columns in the visual except for the DatesKeyMonths[Month] column. Finally, the ALLSELECTED function is used to preserve the filter context for the DatesKeyMonths[Month] column.

By using ALLEXCEPT instead of ALLSELECTED to remove the filter context for all columns except for the DatesKeyMonths[Month] column, you can preserve the filter context from the rows above in the matrix visual. This should give you the result of 2, which is the total number of products sold for the entire year, instead of 1 for a single month.

View solution in original post

2 REPLIES 2
MAwwad
Solution Sage
Solution Sage

 

Based on your explanation, it sounds like you want to ignore the filter context applied by the columns of a matrix visual while still keeping the context from the rows above. To achieve this, you can use the ALLEXCEPT function to remove the filter context for all columns except for the DatesKeyMonths[Month] column, which will be preserved by the ALLSELECTED function.

Here's the modified formula:

 

 
CALCULATE( [Sold], FILTER( Product, Product[Index] = 7 ), ALLEXCEPT( DatesKeyMonths, DatesKeyMonths[Month] ), ALLSELECTED(DatesKeyMonths[Month]) )
 

This formula uses the FILTER function to filter the Product table for the product with an index of 7. The ALLEXCEPT function is then used to remove the filter context for all columns in the visual except for the DatesKeyMonths[Month] column. Finally, the ALLSELECTED function is used to preserve the filter context for the DatesKeyMonths[Month] column.

By using ALLEXCEPT instead of ALLSELECTED to remove the filter context for all columns except for the DatesKeyMonths[Month] column, you can preserve the filter context from the rows above in the matrix visual. This should give you the result of 2, which is the total number of products sold for the entire year, instead of 1 for a single month.

That worked thanks a lot. 

Helpful resources

Announcements
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 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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