Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

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:

SelectBoth.PNG

 

 

When I selected neither item:

SelectNeither.PNG

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

1 ACCEPTED SOLUTION

Hi @Anonymous 

Would you like Page1 or Page2?

Page1

4.png

Page2

5.png

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

View solution in original post

5 REPLIES 5
JacopoMarengo
New Member

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

v-juanli-msft
Community Support
Community 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)

1.png

2.png

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
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

Hi @Anonymous 

Would you like Page1 or Page2?

Page1

4.png

Page2

5.png

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

Anonymous
Not applicable

Yes this 'Measure 2' and 'Measure 3' work well! thanks a lot! I prefer to use 'Measure 2'.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.