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

Filtering in a formule with slicers

I have made a formule for Offer Agreement as follow: 

COUNT ('om_orders'[Ordernr.]) /

CALCULATE (

                      COUNT ('om_orders'[Offertenr.]);

                      'om_orders'[type] = 10

                     ) 

 

I have also slicers for Productgroup and Item and I will use them for this calculation.

At the moment when I choose a Productgroup nothing change.

How can I fix this.

1 ACCEPTED SOLUTION
technolog
Super User
Super User

In Power BI, slicers typically interact with all visuals and formulas on a page. However, your formula is using the CALCULATE function, which can modify the default filter context, so that might be influencing how it responds to slicers.

If you want your formula to respect the slicers on Productgroup and Item, ensure those fields have proper relationships set up with the om_orders table, and also make sure that you're not overriding those filters in your DAX formulas.

Your formula divides the total order count by a count of offers with a specific type. If you want the formula to respond to slicers on Productgroup and Item:

Make sure you have relationships set up between om_orders and the tables containing Productgroup and Item. This is done in the "Model" view in Power BI Desktop.

Modify your formula to not override those filters. Here's the revised formula:

Offer Agreement Ratio =
COUNT('om_orders'[Ordernr.]) /
CALCULATE(
COUNT('om_orders'[Offertenr.]),
'om_orders'[type] = 10,
ALLSELECTED() // This ensures you're keeping the slicers context
)
By using ALLSELECTED(), you respect the slicers' selections while still applying the specific filter 'om_orders'[type] = 10.

However, if you're still facing the issue, double-check the relationships in your data model. Ensure that there are no other formulas or visuals that might be altering the filter context in a way you didn't anticipate.

View solution in original post

1 REPLY 1
technolog
Super User
Super User

In Power BI, slicers typically interact with all visuals and formulas on a page. However, your formula is using the CALCULATE function, which can modify the default filter context, so that might be influencing how it responds to slicers.

If you want your formula to respect the slicers on Productgroup and Item, ensure those fields have proper relationships set up with the om_orders table, and also make sure that you're not overriding those filters in your DAX formulas.

Your formula divides the total order count by a count of offers with a specific type. If you want the formula to respond to slicers on Productgroup and Item:

Make sure you have relationships set up between om_orders and the tables containing Productgroup and Item. This is done in the "Model" view in Power BI Desktop.

Modify your formula to not override those filters. Here's the revised formula:

Offer Agreement Ratio =
COUNT('om_orders'[Ordernr.]) /
CALCULATE(
COUNT('om_orders'[Offertenr.]),
'om_orders'[type] = 10,
ALLSELECTED() // This ensures you're keeping the slicers context
)
By using ALLSELECTED(), you respect the slicers' selections while still applying the specific filter 'om_orders'[type] = 10.

However, if you're still facing the issue, double-check the relationships in your data model. Ensure that there are no other formulas or visuals that might be altering the filter context in a way you didn't anticipate.

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.

Top Solution Authors