KNOWLEDGE BASE

How to Create a Dynamic Date Filter with Slider UI


Published: 13 Dec 2021
Last Modified Date: 13 Dec 2021

Question

How to display the last 3 months of data up to today without changing the slider UI?

       For example if today is:12/11/2021
          The Display range should show: 10/1/2021 - 12/11/2021

Environment

Tableau Desktop

Answer

Follow the steps below to create a dynamic parameter:

Prior setup

 1. Connect to Sample - Superstore.
 2. Drag and drop [Sales] to Rows.
 3. Drag and drop [Order Date] to Colums while right-clicking and select [YEAR(Order Date)]
 4. Drag and drop [Order Date] to Colums while right-clicking and select [MONTH(Order Date)]

Steps to create parameter

 5. Create calculated field as follows.
     Name: Last 3 Months
     Calculation: <
+ DATE(IF  [Order Date] > DATEADD('month',-1,DATETRUNC('month',TODAY()))

                          THEN DATEADD('month',-2,DATETRUNC('month',TODAY()))

                          ELSE TODAY()

                          END)


 6. Right click [Last 3 Months] and create parameter as following.
     Allowable values : Range
     Tick the checkbox for "When workbook opens".
     And select [Last 3 Months] from pull-down menu.
 7. Create calculated field as following.
     Name: Date_Filter
     Calculation: [Order Date] > [Last 3 Months Parameter]
 8. Drag and drop [Date_Filter] to Filters pain and select "True".
 9. Right click [Last 3 Months] and click Show Parameter.
Did this article resolve the issue?