Forum Discussion

crootman's avatar
crootman
Regular Visitor
4 years ago
Solved

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.

 

CustomerCategoryQty
1A1
1B1
1C1
2A1
2B1
3C1
4A1
4B1
4C1
5A1
5B1

 

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

4 Replies

    • crootman's avatar
      crootman
      Regular 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

  • Anonymous's avatar
    Anonymous
    Not 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 🙂 
    • Anonymous's avatar
      Anonymous
      Not applicable

      Drag the field into the table and it will look like this.