Forum Discussion

udas24's avatar
udas24
Frequent Visitor
1 year ago
Solved

Need help with slicer's default selection

Hi All,   I need help with power bi report slicer to select the current month by default. As shown in the below screenshot, currently February 2025 is selected as it is the current month but I want...
  • danextian's avatar
    1 year ago

    hI udas24 

     

    Using Tabular Editor, you can leverage the Group by Columns property to "store a filter by using an alternate value, which represents the key of the entity." Power BI uses this key to store the filter, allowing the corresponding filter value in the visual to change dynamically. For instance, if May-24 is selected in the visual and currently has a key of 0, when June arrives, May will shift to a key of 1, and June will take the key of 0. Consequently, the slicer selection will automatically change to June.

    Demo: https://www.youtube.com/watch?v=MrEAZREQuXM

    Further reading is on the video description.

  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi udas24 , hello danextian, thank you for your prompt reply!

     

    Based on my research, you can use the certified custom visual Preselected Slicer to complete the task.

     

    Follow these steps to create the necessary measures:

     

    Current Period = 
    VAR MaxPeriod = MAXX(ALL(PeriodTable),PeriodTable[Period])
    RETURN MaxPeriod
    
    IsCurrentPeriod = 
    IF(SELECTEDVALUE('PeriodTable'[Period]) = [Current Period], TRUE(), FALSE())

     

    Since the Preselected Slicer requires a Dirty Status field containing Boolean values, you need to create a dummy table.

     

    Dummy = UNION ( SELECTCOLUMNS ( { TRUE }, "Dummy", TRUE ), SELECTCOLUMNS ( { FALSE }, "Dummy", FALSE ) )
    

     

    Result for your reference:

     

    Hope the following article is helpful to you:

    Exploring slicer default selections – Owen Auger's BI Blog

    Best regards,

    Joyce

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.