Search code examples
powerbipowerbi-desktop

Keep a category in a filter selected, but hide it from the filter box


I have a filter box with 4 categories in it, I want a specific category to be always selected and the user to not be able to turn it off, so the user can only choose between the three other categories.

current filter

This is how the filter box currently looks, but I want it to look like this.

what I want

I tried to use the Page filter settings, however it unchecks the first emtpy category, which i want it to be always selected.

can you help me here ?

Thanks


Solution

  • There isn't an easy way to achieve this. It can be done by using a Measure(s) which will need to be added to each and every visual on the page that you want to be sliced.

    Slicer
    Your slicer will need to be from a separate table to the ones used in a visual. If you don't have a separate table, then you can create one with:

    Slicer Type = DISTINCT( 'YourTable'[Type] )
    

    You don't need to have relationships created for this new table (but you can if you want).
    In the Filter pane, hide the empty category.

    Measure
    Create a Measure similar to:

    Type count = 
      CALCULATE(
        COUNTROWS('YourTable'),
        REMOVEFILTERS('Slicer Type'[Type]),
        KEEPFILTERS(
          'YourTable'[Type] IN DISTINCT('Slicer Type'[Type]) || 
          'YourTable'[Type] = ""
        )
      )
    

    Add this measure to your visuals, or modify existing measures used in your visuals with the same concept as above.