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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
dbandrews
Regular Visitor

AND Slicer condition with multiple many-to-one tables

Hi Everyone,

 

I'm attempting to get a slicer to behave like AND instead of an OR - I've attempted to implement the solutions I've found on here already (https://community.powerbi.com/t5/Desktop/Slicer-with-quot-AND-quot-logic/td-p/592018) but my data model/task is slightly different and I can't get it quite right.

Problem: Given the following data model

dbandrews_0-1662046846871.png

 

I want to have a matrix visual where I can evaluate what fraction of each customer's orders have a certain SuperWidget in the order, while also having certain Widgets present in the order, filtering on multiple Widgets all being present (the AND condition).

What I have so far:

dbandrews_1-1662048454452.png

 

The issue I'm having is highlighted in red in the screenshot above - I want to reduce the denominator by filtering where multiple Widgets are present in the same SaleID. I then want to have the fraction of relevant calls filtered by Widget, where the selected SuperWidget is present.


Where the fractions are calculated with:

 

 

Fraction_sales_with_superwidget = 
VAR COUNT_SALES_UN_FILTERED = CALCULATE(DISTINCTCOUNT(SuperWidgetSales[SaleID]), REMOVEFILTERS(SuperWidgetSales[SuperWidget]))
VAR COUNT_SALES_FILTERED = DISTINCTCOUNT(SuperWidgetSales[SaleID])

RETURN DIVIDE(COUNT_SALES_FILTERED, COUNT_SALES_UN_FILTERED)

 

 


And my DAX so far to create the AND condition is applied to the Matrix visual as filter:

dbandrews_2-1662048548776.png

 

And is defined as:

 

 

Matches_all_selected_widgets = 
VAR _EmptySlicer = 
    CALCULATE(ISFILTERED(WidgetSales[Widget]), ALLSELECTED(WidgetSales[Widget])) = FALSE()

RETURN
IF (
    NOT (_EmptySlicer),
    IF(CALCULATE(DISTINCTCOUNT(WidgetSales[Widget]), ALLSELECTED(WidgetSales[Widget]))
    >= COUNTROWS(ALLSELECTED(WidgetSales[Widget])),
    1
    ),
  1
)

 

 


I realize this data model might be sub-optimal for this problem, so if you have any suggestions to improve that to make this easier to solve I'm happy to update. My actual data model has millions of rows on the many side of these relationships so performance is important.


Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@dbandrews , Based on what I got, refer if my video can help

And for Selected Values, All selected values are present: https://youtu.be/X5T4rIZovHk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@dbandrews , Based on what I got, refer if my video can help

And for Selected Values, All selected values are present: https://youtu.be/X5T4rIZovHk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.