Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

How to count selected items in slicer?

I created a slicer with two items (Supplier 1 and Supplier 2), I was trying to count the selected items from this slicer, but what I found is that the count result would be the same when I selected both or de-selected both.

The measure I created is: CountSupplier = COUNTROWS(FILTERS('Sheet1'[Supplier Name]))

When I selected both:

 

 

When I selected neither item:

I need the measure give the count result '0' when I de-select both.

5 Replies

  • v-juanli-msft's avatar
    v-juanli-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous 

    Create a new table and don't connect this table to other tables

    Table2 = VALUES(Table1[name])

    Add Table2[name] in the slicer, add Table1[name] in the table visual.

    create a measure in Table1

    Measure = 
    IF(ISFILTERED(Table2[name])&&SELECTEDVALUE(Table1[name]) in VALUES(Table2[name]),1,0)

    Best Regards
    Maggie

    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Maggie,

      When I selected both items in the slicer, I need the measure give result of '2' instead of '0'. Here is a list for the measure results I want:

      Select NO item: measure = 0

      Select 1 item: measure = 1

      Select 2 item: measure = 2

      ...

      Actually here I just gave an example of 2 items in the slicer, what about if there are more items in the slicer?

      Thanks!

      Michael

      • v-juanli-msft's avatar
        v-juanli-msft
        Icon for Community Support rankCommunity Support

        Hi Anonymous 

        Would you like Page1 or Page2?

        Page1

        Page2

        Measure 2 = IF(HASONEVALUE(Table1[name]),[Measure],SUMX(Table1,[Measure]))
        
        Measure 3 = SUMX(ALL(Table1),[Measure])

        This works not only for tow items but also work for more.

         

        Best Regards

        Maggie

  • How to have the column "value" in Table 1? Should I sipmy add a columns and fill with "1"? If I do this, I do not see the symbol "Σ" next to value. Thank you