Forum Discussion

bvy's avatar
bvy
Helper V
4 years ago
Solved

Count selected slicer values -- BUT exclude two explicit entries

Hello I have a slicer with values A, B, C, D and E (for example). I need DAX to return the number of items selected -- BUT exclude A and/or B from the count if they're selected. 

 

So I can use this to get the count of selected values, but not sure where to filter out (ignore) A and B from the count. 

 

_count = IF(ISFILTERED(Slicer[ABCDE]), COUNTROWS(VALUES(Slicer[ABCDE])))

 

Thanks, 

  • bvy's avatar
    bvy
    4 years ago
    Thank you. This seemed to work as well. 
    COUNTX(FILTER(ALLSELECTED(Table[Option]), NOT Table[Option] IN {"A", "B"}), Table[Option])

4 Replies

  • Hi bvy ,

     

    Assuming there is an existing relationship between the slicer table and table being counted, try something like below:

    count =
    CALCULATE (
        COUNTROWS ( Table[Column] ),
        FILTER ( Slicer, NOT VALUES ( Slicer[Value] ) IN { "A", "B" } )
    )

     

    • bvy's avatar
      bvy
      Helper V

      Thank you but nothing about that seems to work. For example, COUNTROWS() takes a table as an argument, not a column. The FILTER seems to ignore selected values.

       

      Everything is in one table currently. 

       

      Anyone else? 

      • danextian's avatar
        danextian
        Super User

        Hello, Please try this:

        Value without A and B = 
        CALCULATE (
            COUNTROWS ( 'Table' ),
            FILTER ( Slicer, Slicer[Column] <> "A" && Slicer[Column] <> "B" )
        )