Forum Discussion

arawo's avatar
arawo
Frequent Visitor
1 year ago
Solved

List slicer - Show only selected items

Hello, I would like to ask you for help in setting up the list slicer. In my report I have a table with all the articles stored in my warehouse and current stock of the articles. Sometimes I want to...
  • DataNinja777's avatar
    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,