Skip to main content
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Helper II
Helper II

Custom year slicer

I have a year slicer in which there are 4 years.


For this current year i have used dax which is:

YearSlicer = if([Year]=year(today()),"Current Year",CONVERT([Year],STRING)).

But the requirement is instead of current year it should dispaly "2023" and by default the current year should be selected. 
And only last 4 years should be visible. For example: 
If the current year is 2024 the years visible should be:
2024, 2023, 2022 and 2021. 

Thank you in advance.

Super User
Super User

Yes, as long as the dataset is refreshed so that Year Offset column = 0 for the current year.


The slicer selection is actually Year Offset = 0. It just displays the appropriate year as a label in place of 0, and the label will update to whichever year corresponds Year Offset =0.

Owen Auger
Did I answer your question? Mark my post as a solution!

okay. And is it possible if we do this in dropdown?
And in the year offset column we have defined the end date. Will it dynamically change if the year changes? 

Right now, dropdown is unfortunately not possible with this new Slicer visual. And the original Slicer has no option for displaying labels and hiding values 😞


Yes, the "Year Offset" column will dynamically change on refresh as long as it is defined in a calculated column or table relative to TODAY() (using DAX) or similarly in Power Query.


My example version was defined in a calculated table using the TODAY() function to determine the current year.

Owen Auger
Did I answer your question? Mark my post as a solution!

What if i selected year in dropdown slicer and used year offset in filter?


Will this work if the date got changed?


I don't quite follow - could you clarify what you mean by that?

Owen Auger
Did I answer your question? Mark my post as a solution!
Impactful Individual
Impactful Individual

Why don't you just select the current year in the default published report? And set a hidden page filter with the last three years plus the current one? 

And just change this setting once per year, on January 1st?

thanks for replying @AliceW ,
We tried this method but this will not be a good practice.

Super User
Super User

@Sanskruti ,

You don't have direct option to do that. If you need some workaround may be you can try the approach mentioned in below thread,

Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


Thank for replying @Arul ,
will look into it.

Not applicable


Super User
Super User

Hi @Sanskruti 

You can try the Preselected Slicer custom visual, assuming you are happy with the visual's appearance.

(Similar functionality should be coming to the core slicer visual at some stage but not yet.)


The sample workbook provided by the developer for this particular visual contains instructions, but I have attached a small example similar to what you have described, using a 'Date' table.


Components of this example:

1. A measure Current Year Flag, used in the Pre Selection field of the visual:

Current Year Flag = 
MAX ( 'Date'[Year] ) = YEAR ( TODAY () )

2. A measure Last 4 Years Flag used as a visual-level filter:

Last 4 Years Flag = 
VAR MaxYear = MAX ( 'Date'[Year] )
VAR CurrentYear =
    YEAR ( TODAY () )
    INT (
        AND (
            MaxYear <= CurrentYear,
            MaxYear >= CurrentYear - 3

3. Once the visual is set up it looks like this:



When the report page is opened, the current year will be selected (as long as it exists in the table).


Does this work for you?




Owen Auger
Did I answer your question? Mark my post as a solution!

Hello @OwenAuger ,
Thanks for replying but we dont want to use custom visuals.
Thank you.

Understood 🙂
Would you be willing to use the "Slicer (new)" visual?

It would require the items to appear as buttons.


If you have a "Year Offset" column, you could place a "Year Offset" field on the slicer, filtered to zero (i.e. current year)

Then switch off Values (-3, -2, -1, 0) and instead show a Label defined by a measure returning the year (2020, 2021, 2022, 2023).



Example attached.


Owen Auger
Did I answer your question? Mark my post as a solution!

This works @OwenAuger ,
But will the current year be selected by default?
Like when the year get 2024 the slicer should display and get selected as 2024.

Helpful resources

Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.


Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors