Showing results for 
Search instead for 
Did you mean: 
Helper II
Helper II

Implementing AND/OR logic in Slicers

Hi Folks,

I came across a client requirement today stating the need of Slicers to work with AND/OR logic. The slicers in Power BI by default work by OR logic. So, I created a simple measure in order to implement AND logic. 

Dataset consists of following two tables.










Now, I want the name of students who opted for both subjects 'Maths' and 'English' and not 'Maths' or 'English' or 'both'. 

1. First of all, I took Subject column values as slicer values and dragged Name and Marks to grid.

2. Now, I created a measure giving me the count of subjects [SubjectCount]

3. Created another measure comparing the count of subjects selected on slicer and that of rows filtered from table. This measure returns 1 when a student has opted for all selected subjects, else 0.





4. Now, we add this measure to filter pane of grid visual such that it's value is greater than 0.


And that's it! This way, the slicer works by AND logic. Please find the snapshot below.


Do let me know if there is a simpler way to achieve this.


Thanks and Regards,
Nikita Dalela | BI Consultant
Nice Software Solutions

Super User
Super User

@NikitaDalela - Right, there are existing solutions for AND slicers, like this one:


Also, what it sounds like you implemented is basically the Complex Selector pattern:

@ me in replies or I'll lose your thread!!!
Check out my External Tool for Power BI Desktop! Microsoft Hates Greg's Quick Measures
YouTube Channel! Microsoft Hates Greg
Check out my latest book!

Helpful resources

Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

Top Solution Authors