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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
Super User
Super User

 

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
Super User
Super User

 

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors