KNOWLEDGE BASE

## Using Parameters to Convert a Date Filter to Show Different Date Terms

Published: 27 Apr 2023

### Question

How to convert a date filter to allow selection of month/quarter/semester/year?
Before:

After:

### Environment

• Tableau Desktop 2021.3 and newer
• Windows 10
• Excel

The solution posted here and in the attached package workbook (see "Attachments" to the right of this text), is to use parameters to convert a date filter to allow the viewer to select different date terms such as month, quarter, semester, or year.

1. Create a parameter with the name Term as shown below:

2. Create the following Calculated fields:
1) name: TS_month
value: STR(DATEPART('year', [Order Date])) +"Y-"+ STR(DATEPART('month', [Order Date]))+"M"
2) name: TS_quarter
value: STR(DATEPART('year', [Order Date]))+"Y-"+STR(DATEPART('quarter', [Order Date]))+"Q"
3) name: TS_semester
value: IF DATEPART('quarter', [Order Date]) < 3 THEN STR(DATEPART('year', [Order Date]))+'Y-Semester 1' ELSE STR(DATEPART('year', [Order Date]))+'Y-Semester 2' END
4) name: TS_year
value: STR(DATEPART('year', [Order Date]))+"Y"
5) name: TS_termfilter
value: IF [Term]="month" THEN [TS_month]
ELSEIF [Term]="quarter" THEN [TS_quarter]
ELSEIF [Term]="semester" THEN [TS_semester]
ELSEIF [Term]="year" THEN [TS_year]
END
3. Drag Ship Mode and Segment to Columns and Sales to the Rows.
4. Right-click Term and select Show Parameter.

5. Right-click TS_termfilter and select Show Filter.

6. Change Term to select month/quarter/semester/year filters.