Forum Discussion
Custom year slicer
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.
- OwenAuger2 years agoSuper User
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.