Forum Discussion

Lucy01's avatar
Lucy01
Icon for Helper II rankHelper II
17 hours ago

Make Slicer Default to Specific Month

I would like to find a way to make my monthly slicer default to the most recent month whenever the report is opened, but also allow users to change the month selected. I’d like to be able to do this with DAX rather than adding a calculated column or additional tables. So far, the closet method I’ve found is this tutorial with the below DAX

Master Slicer Defaults in Power BI with DAX Functions | Scenario-based interview questions

‘MainTable’[Month] = IF ( NOT ISFILTERED('YourTable'[Category]), CALCULATE ( SUM('YourTable'[Sales]), 'YourTable'[Category] = "Electronics" ), SUM ( 'YourTable'[Sales] ) )

But I don’t want to Calculate or SUM any information, I just want my slicer to default to the most recent month. Is there a way to modify this DAX for that purpose? I’m open to changing the DAX monthly if it won’t update automatically, but at the very least I’d like to able to set the slicer to a specific month.

Thank you

6 Replies

  • Hi Lucy, DAX can change what a measure returns when the slicer is cleared, but it can’t select a month in the slicer itself.

    • Latest month with data: Use a Date picker slicer with your existing fact table’s date column. Set it to This → Month with Last date as the anchor. If your latest record is October 18, the slicer opens on October. Use a date column that ends with your data, since a calendar extending into the future can anchor it to a month with no records.
    • Current calendar month: Use Today as the anchor. Viewers can still pick another date range. If you want the published default restored on each visit, disable Persistent filters in the report settings.

    If you need to keep the existing Month/Year dropdown, select the month you want, save, and publish. That gives users an editable default you can update manually.

  • Hi Lucy01​ 

    You can leverage the Group by Columns property, which you need to configure in Tabular Editor. This allows Power BI to "store a filter by using an alternate value, which represents the key of the entity." Instead of storing the actual filter value, Power BI uses this key to maintain the selection, allowing the corresponding value displayed in the visual to change dynamically.

    For example, if you select May-24 in the visual and it currently has a key of 0, when June arrives, May shifts to key 1, and June takes over key 0. As a result, the slicer selection automatically moves to June without requiring you to change it manually. https://youtu.be/MrEAZREQuXM

    Alternatively, you can use the Button slicer with a column that identifies the current month. Disable the callout and use the label to display the actual month name.

    You can achieve something similar with the List slicer. The individual button will display the actual month name, but the selected value will be the underlying column value, which in this case is "Current Month." https://youtu.be/put_52SkQlk  https://youtu.be/iSQ9n1z9gYA

  • Hello Lucy01​,

    There's a much simpler solution if you're happy using a date-based slicer. Power BI's newer Date picker slicer supports relative selections anchored to the latest date in your data.

    • To configure it, add your date column to a slicer, then select Format visual > Slicer settings > Options > Date picker.
    • Choose a relative selection for the latest calendar month and set the anchor to Last date.

    If you specifically need a Month/Year dropdown that automatically selects the latest available month, that requires a different workaround.

    Microsoft's Date slicer documentation explains the relative selection options.

    Hope this helps.

  • Hi,

    DAX can't actually change the selected value in a slicer, so I don't think the formula from the video will work for this.

    If you're looking for the current month, a relative date slicer is probably the easiest way. Users can still change the date range themselves.

    For a regular dropdown, you can save a specific month as the default, but it won't update on its own. And if you mean the latest month with data rather than the current month, that's a different story.

    Also, keep in mind that Power BI Service can remember previous slicer selections through persistent filters.

  • rampie's avatar
    rampie
    Icon for Kudo Commander rankKudo Commander

    A slicer default can't really be set with DAX, but you can get the same result natively. Try putting your date column (not the auto date hierarchy) in the slicer and switching the style to Relative date, set to "This month". Or use Date picker anchored to Last date if you want it to follow your latest data instead of today. Either way it opens on the current month and users can still change it.

    https://learn.microsoft.com/en-us/power-bi/visuals/desktop-slicer-filter-date-range

    Hope this helps!

    https://www.linkedin.com/in/richard-ampie-218a07247/