Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Setting Default Slicer Value

Hi there,

 

I'm currently trying to find a way to set the default value of a slicer, or something that produces similar results. I have a category that I'd like to be filtered out by default in my dashboard. I was thinking of either having the default slicer value excluding this category, or having a slicer that has the option to include the category with values for yes and no, or something similar. 

 

Is somethig like this possible within PowerBI? Thanks for any assistance with this. 

  • Hi, Anonymous 

     

    The slicer cannot be set to the default value unless the slicer is set to single selection.
    But we can make the slicer look like the default value is set through some other methods.


    For example, in the following example, I exclude the product "VTT" by default and create a measure to detect the selected value of my slicer. If the slicer is not selected, the product "VTT" will be excluded by default.
    We need to create a summary table to get all the products, and then use the summarized product field to create a slicer. Then create the measure above to counter the slicer's choice. This is similar to a switch, and finally we can filter on the visual to get the desired result.

     

    Here I use the official sample data: financials.xlsx

    you can get it from "Try a sample data" 

    measure:

     

    _Default Slicer = 
    VAR _total =
        CALCULATE ( DISTINCTCOUNT ( P[Product] ), ALL ( P[Product] ) )
    VAR _ProductList =
        SUMMARIZE ( ALLSELECTED ( P ), P[Product] )
    VAR _countSelected =
        COUNTROWS ( _ProductList )
    VAR _except_Default = { "VTT" }
    // we can also set a list of default selected values like:
    // var _selected_Default={"VTT"}
    // just to change the "N" to "Y".
    VAR _if =
        IF (
            _countSelected < _total,
            IF ( MAX ( 'financials'[Product] ) IN _ProductList, "Y", "N" ),
            IF ( MAX ( 'financials'[Product] ) IN _except_Default, "N", "Y" )
        )
    RETURN
        _if

     

    result:

    Please refer to the attachment below for details

     

    In addition, you can also set default values in the filter pane, for example, set the default country to Canada.

    Filtering panes is also a feasible method.

     

     

    Hope this helps.

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

2 Replies

  • Anonymous there is no option to set the default value for the slicer. 

     

    Follow us on LinkedIn

     

    Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

     

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Hi, Anonymous 

     

    The slicer cannot be set to the default value unless the slicer is set to single selection.
    But we can make the slicer look like the default value is set through some other methods.


    For example, in the following example, I exclude the product "VTT" by default and create a measure to detect the selected value of my slicer. If the slicer is not selected, the product "VTT" will be excluded by default.
    We need to create a summary table to get all the products, and then use the summarized product field to create a slicer. Then create the measure above to counter the slicer's choice. This is similar to a switch, and finally we can filter on the visual to get the desired result.

     

    Here I use the official sample data: financials.xlsx

    you can get it from "Try a sample data" 

    measure:

     

    _Default Slicer = 
    VAR _total =
        CALCULATE ( DISTINCTCOUNT ( P[Product] ), ALL ( P[Product] ) )
    VAR _ProductList =
        SUMMARIZE ( ALLSELECTED ( P ), P[Product] )
    VAR _countSelected =
        COUNTROWS ( _ProductList )
    VAR _except_Default = { "VTT" }
    // we can also set a list of default selected values like:
    // var _selected_Default={"VTT"}
    // just to change the "N" to "Y".
    VAR _if =
        IF (
            _countSelected < _total,
            IF ( MAX ( 'financials'[Product] ) IN _ProductList, "Y", "N" ),
            IF ( MAX ( 'financials'[Product] ) IN _except_Default, "N", "Y" )
        )
    RETURN
        _if

     

    result:

    Please refer to the attachment below for details

     

    In addition, you can also set default values in the filter pane, for example, set the default country to Canada.

    Filtering panes is also a feasible method.

     

     

    Hope this helps.

     

    Best Regards,
    Community Support Team _ Zeon Zheng
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.