How To Filter Both Axis And Data Based On Relative Date Filter Selection

Published: 20 Aug 2020
Last Modified Date: 08 Jul 2022


How to filter both axis and data based on relative date filter selection  i.e. the axis should be in months when last 6 months is selected from relative date and axis should be in years when last 1 year is selected from relative date filter


  • Tableau Desktop


1. Create a parameter Choose Duration like below
User-added image
2. Create a calculation called Dynamic axis like below:

IF [Choose duration]='year' then STR(YEAR([Order Date]))
ELSEIF [Choose duration]='month' then  DATENAME('month',[Order Date]) +', '+
                                        STR(YEAR([Order Date]))
ELSEIF [Choose duration]='day' then DATENAME('month',[Order Date]) +' '+
                                    STR(DAY([Order Date]))+', '+
                                    STR(YEAR([Order Date]))

ELSEIF [Choose duration]="quarter" then STR(YEAR([Order Date])) + " " + "Q"+ DATENAME('quarter',[Order Date])


3. Drag Dynamic axis calculation on rows and show the parameter Choose Duration
4. Use the date field on Filters with relative date as a option
5. Choose the axis representation from parameter and filter with relative date
User-added image
Did this article resolve the issue?