Skip to main content
cancel
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

Reply
andy808
Helper II
Helper II

Dynamic Date Slicer - show all years but default selection to last 3 years

Is there a way to have a slicer show all the years but be able to pre-select (default) to the last 3 years? These last 3 years would need to be dynamic - ie. this year 2024, 2023, 2022 are preselected and next year 2025, 2024, 2023 are preselected.

 

A requirement we use on all pages is a Clear All Filter Bookmark which I would need this Date slicer to reposnd to as well. Right now I pre-select 2024, 23, 22 and have saved this as the Clear All Filters Bookmark so the page will always returns back to these years.

 

I have a Calendar Auto Date table with Date[Date] column relationship with the FactTable(FiscalYearDate] column. Both are Date data types.

 

andy808_0-1708979735285.png

 

1 ACCEPTED SOLUTION

I ended up just doing this:

CustomDates = IF('Date'[IsCurrentFY] = [CurrentFiscalYear], [CurrentFiscalYear], IF('Date'[IsCurrentFY] = [CurrentFiscalYear] - 1, [CurrentFiscalYear] - 1, IF('Date'[IsCurrentFY] = [CurrentFiscalYear] -2, [CurrentFiscalYear] -2, 'Date'[IsCurrentFY)))
 
Thank you for your help 🙂

View solution in original post

5 REPLIES 5
v-jiewu-msft
Community Support
Community Support

Hi @andy808 ,

Please try the following methods and check if they can solve your problem:

1.Create the simple table. Use the calender to create the table.

 

FactTable = CALENDAR(DATE(2020,1,1),DATE(2024,2,27))

 

vjiewumsft_0-1709002655586.png

2.Click "New column" in the table to create a calculated column, it is used to define what rows are the last three years and other are just show the Date type.

 

Fiscal year Date = 
VAR _max_date = MAX ('Table'[Date])
VAR _last_three_year = YEAR(_max_date) - 2

RETURN
IF (
    [Date].[Year] >= _last_three_year, "Last 3 years",
    FORMAT ( [Date], "yyyy" )
)

 

3.Drag the year date column into the slicer visual.

vjiewumsft_1-1709002700441.png

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

I ended up just doing this:

CustomDates = IF('Date'[IsCurrentFY] = [CurrentFiscalYear], [CurrentFiscalYear], IF('Date'[IsCurrentFY] = [CurrentFiscalYear] - 1, [CurrentFiscalYear] - 1, IF('Date'[IsCurrentFY] = [CurrentFiscalYear] -2, [CurrentFiscalYear] -2, 'Date'[IsCurrentFY)))
 
Thank you for your help 🙂

Thanks for your resonse. I have a Calendar auto table so good there. Last 3 years is an option but the requirement is for the user to choose any year individual but have the last 3 years 2024, 2023, 2022 all selected as default. My thought is to create a calculated column where:

 

1 - 2024 = "Current FY"   

2 - 2023 = "Last FY"    essentially current FY - 1

3 - 2022 = "3rd FY"     essentially current FY - 2

 

Do you know the dax for this calculated column? We have a FY July-June

 

 

lbendlin
Super User
Super User

Remove the slicer and instead use the Filter Pane. It has Relative Dates features, and users can change the filters as needed.

This is one possible solution, thank you. Our current reports do not have the filter pane visible to users, but it an option.

Helpful resources

Announcements
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.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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