Forum Discussion

majid154a's avatar
majid154a
Helper II
6 months ago
Solved

Year updated automatically

Dear Experts,  I have a slicer set as a dropdown, and it is based on a date field. For example, I currently have years like 2023, 2024, and 2025. The slicer is now selected on 2025.  When the dat...
  • cengizhanarslan's avatar
    6 months ago

    Slicers remember their last state. When 2026 is added to the model, Power BI will add it to the list, but it will not auto-select it. So instead of using Year column in your slicer, create a new column that contains value "This Year" instead 2026(I mean current year here). Then use that field in your slicer. E.g. slicer would be:

     

    2023

    2024

    2025

    This Year

     

    • Calculated column in your Date table:
    Year Label =
    IF (
        'Date'[Year] = YEAR ( TODAY() ),
        "This Year",
        FORMAT ( 'Date'[Year], "0000" )
    )

     

    • Select Year Label

    • Set Sort by column → Year

  • danextian's avatar
    6 months ago

    Hi majid154a 

    A common solution and as what others have already suggested is to substitute the current year with another text like this year but if you want to  keep the value as-is is to 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. I have a tutorial on this on YouTube - https://youtu.be/iSQ9n1z9gYA