Forum Discussion
List slicer - Show only selected items
- 1 year ago
Hi arawo ,
You can modify your Power BI report to achieve the desired slicer functionality. While there isn't a direct, single-click setting for this, you can create a slicer that shows all articles when nothing is selected and then dynamically updates to show only the selected items once a choice is made. This is accomplished by creating a simple DAX measure and applying it as a filter directly to the slicer visual itself.
First, you will need to add a new measure to your model. You can do this by navigating to the Modeling tab and selecting New Measure. In the formula bar, you should enter the following DAX expression, making sure to replace 'YourTable' and [Article] with the actual names of your table and the article column you are using in the slicer.
SlicerFilter = IF(ISFILTERED('YourTable'[Article]), 1, 0)After creating this measure, select the slicer visual in your report canvas. With the slicer selected, go to the Filters pane. Drag the SlicerFilter measure you just created into the "Filters on this visual" section. Once it's there, expand its options and set the filter condition to is 1. This configuration makes it so the measure returns a 1 whenever the article list is filtered. By filtering the slicer visual to only show when the measure is 1, it effectively hides the unselected items as soon as a selection is made. If you clear the selection, the condition is no longer met, and the slicer reverts to showing the full list of all articles.
Regarding your alternative question, having selected items appear at the top of the slicer is the default behavior in Power BI. When you select any item in a list slicer, Power BI automatically moves it to the top of the list and displays a faint line to separate it from the unselected items below. You do not need to configure any special settings to enable this functionality. If you are not observing this behavior, you may want to ensure your version of Power BI Desktop is up to date.
Best regards,
I guess I didn't fully understand what I had to do. I added a new measure, added a "slicer" (not a text slicer, not a list slicer, just a slicer) and added my measure to Filters on this visual, but then unfortunately I can't change the filter condition, they remain "is less than" and the function is kind of blocked.
I managed to do it I guess. Your method works, but I don't know if I set it up correctly.
In the first slicer I added a measure as you suggested and set the Filters on this visual measure = 1. I added a second slicer and there after pasting the article number in the first slicer the pasted numbers are selected and only they are on the list.