Home Personal Showing the number of selected items in a #PowerBI slicer

Showing the number of selected items in a #PowerBI slicer

by Prathy Kamasani

In one of the projects I was working on, I received feedback saying it is hard to understand how many items they have selected in a slicer, and it is not the first time I came across this. It is a valid point, especially when you have quite a few items in a slicer, you use a search bar to look for items, you select a couple, but you were not sure how many were selected.

Obviously, there are many solutions to one problem. I have seen many reports displaying custom labels to handle this situation. Still, after some research for a better UX, I found this example on the dribble, which looked like an excellent design method.

shot.gif (800×600) (dribbble.com)

And 

And doing this in 

 

The logic here, I will use a DAX measure to figure out how many items are selected and count those Items to display in an object. I can display this many ways, but I went for a Shape. Having shape allows me to use a shape type as a background; I can use a dynamic DAX expression to show the value. The only thing to note is, my DAX expression has to be a string type. Hence, I created my measure like below. Next is the slicer visual. By default, I enabled the slicer header and used an empty character as text in the slicer header. If I keep the slicer header off, whenever I hover over a slicer, it jumps down/up to make more options visible. If I keep the slicer header on, that won’t be an issue. The only way to have the slicer header off with no title and no tooltip to display is by using Empty Character. So, I used an empty character as the title for the slicer header. Then I went to change the title to DAX measure. And then I grouped altogether, slicer and the shape. Now when I select multiple items, it nicely shows how many items were selected. When none is selected, it shows all the items available in the slicer. In this example, I don’t have many values, so a nice round shape works but based on several results, I may go for different Shape types and keep my shape. But to make it work perfectly, I mean to make this shape to show the right number irrespective of other visuals cross-filtering can be a tiring job. One way is to make all the rest of the visuals do not interact with this shape. That can be time-consuming when you have a lot of objects on a page. The other way to handle this is by creating a new table and creating a relationship. So, in this example, I have Artists and their Total streams. I am using Artist in my slicer. When I select an Artist in another visual, by default, my measure also gets filters. If I create another table with a distinct Artist use that in my slicer, and use that column to count, and in all other visuals, I use the Artist from a different table; then I get the result I want.1. Created an Artist table2. Create a relationship between my streams table and Artist table3. Update my slicer to get Artist names from Artist table4. Update measure to get Artist name from Artist table now. Cross-filtering doesn’t impact the value I’m showing. I hope this inspires someone out there.

You may also like

4 comments

Jennifer Boudreau 14 December 2023 - 11:11 pm

This looks great…you have won me over to think more about the user experience! I love how you are able to auto-hide the filter panel in this dashboard. Can you share what type of object you are using to get this hover capability? Are they buttons with filters on top?

Reply
Ankit Rohatgi 13 December 2022 - 4:12 pm

This is exactly I am wondering at! Kindly help!

Reply
datenanalyst 21 May 2022 - 11:06 am

Great explanation of a great feature; thanks

Reply
Didier Terrien 29 October 2021 - 12:53 pm

Hello Prathy,
Thank you for the post, that’s brilliant ! I wonder how you make slicers appear smoothly clicking on the search box. I think it cannot be a bookmark. And which custom visual do you use for the search box ? I use the text filter which will be deprecated soon so I’m looking for a good alternative.
Thanks a lot in advance

Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.