Forum Discussion
How to do an AND / OR Filter
Hi,
I have a table sample below and having trouble figuring out how to do an "AND" filter dynamically in a Power BI.
| Customer | Category | Qty |
| 1 | A | 1 |
| 1 | B | 1 |
| 1 | C | 1 |
| 2 | A | 1 |
| 2 | B | 1 |
| 3 | C | 1 |
| 4 | A | 1 |
| 4 | B | 1 |
| 4 | C | 1 |
| 5 | A | 1 |
| 5 | B | 1 |
What I would like to do is the following:
- Count the number of customers on each Category - This I can do and is pretty simple with any of the existing tools
- Count the number of customers that contains more than 1 Category (But has to contain both if 2 are selected):
- I.e. If I select A and C there should be 2 Customers selected only as they are Customers 1 and 4
How would I go about that?
Thanks in advance
crootman , Refer my video on a similar topic can help
And for Selected Values, All selected values are present: https://youtu.be/X5T4rIZovHk
4 Replies
- amitchandakSuper User
crootman , Refer my video on a similar topic can help
And for Selected Values, All selected values are present: https://youtu.be/X5T4rIZovHk
- crootmanRegular Visitor
Thanks that works for what I want to do.
Do you have a link to the Power BI file? The one in the video is either outdated or contains incorrect information. I can't find the tabs that you refer to
- AnonymousNot applicable
Hi,
For usisng and "AND" clause in power bi, you can use a measue of this sort:Your_Measure = IF( CALCULATE( DISTINCTCOUNT('Test_and or'[Category]),ALLSELECTED('Test_and or'[Category]))= COUNTROWS(ALLSELECTED('Test_and or'[Category])),MIN('Test_and or'[Customer]))
Let me know if that helps 🙂- AnonymousNot applicable
Drag the field into the table and it will look like this.