KNOWLEDGE BASE

Creating a Relative Date Filter with Slider


Published: 10 Sep 2013
Last Modified Date: 09 Jan 2017

Question

How to create a quick-filter slider that filters the view based on a date relative to today’s date.

Environment

Tableau Desktop

Answer

The following steps use the view and data source included in the attached Tableau workbook, relative-date-slider.twbx. Download the workbook to follow along with the steps.

  1. Select Analysis > Create Calculated Field.
  2. Name the field Relative Date (Months), and, in the Formula box, build the following formula:

    DATEDIFF('month',<date>,Today())

    Where <date> is the name of the date field you want to use in the filter.

  3. From the Measures pane, drag Relative Date (Months) to the Filters shelf.
  4. In the Filter Field dialog box that opens, click Next.
  5. In the Filter dialog box that opens, click OK.
  6. From the drop-down menu on the instance of Relative Date (Months) that is on the Filters shelf, select Show Quick Filter.

Using the slider, you can specify the number of months to display in the view, between today and the <date> field.

Tip: You can edit the title of the quick filter to make it more intuitive for your viewers. For example, change it to Months from Today.

Did this article resolve the issue?