March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Hello,
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.
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.
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.
What if i selected year in dropdown slicer and used year offset in filter?
Will this work if the date got changed?
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.
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,
https://community.fabric.microsoft.com/t5/Desktop/Set-default-value-of-current-year-in-slicer/td-p/2...
ok
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 () )
RETURN
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?
Regards
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.
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.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
124 | |
87 | |
87 | |
70 | |
51 |
User | Count |
---|---|
205 | |
153 | |
97 | |
79 | |
69 |