There are occasions where it’s necessary to use a Tableau date parameter as a filter. There are situations where a “normal” Tableau filter do as wanted, for example, when choosing a month and also wanting to see other related months.
Using a parameter as month filter offers flexibility not available with a standard date filter.
When using a normal Tableau filter, if choosing January of this year, for example, all data that isn’t January of this year is removed.
When the user also wants supplemental information, such as the YoY change, or to see the numbers from last month, this isn’t possible using a normal filter. This is when using a parameter as a filter is a good option.
How to use a parameter as a month filter
To create a parameter is simple; right click in the field names area and Create – Parameter.
Tableau parameters can be a number of different data types. But when using a parameter as a date part I prefer to keep the parameter data type as a Date (or DateTime, depends if time is a factor in the filtering).
Keeping it as a Date means better performance. However, it also requires a good understanding of Tableau date functions.
For example, for the user to select a month and year combination, Jan 2020, for example, I have seen this created as a String parameter data type. This does work, but in related calculated fields it means conversion of date to string OR conversion of the parameter string to a date.
Neither conversion is necessary if keeping the parameter output as a Date data type.
Create and use a Date parameter
To use a parameter as a month filter means we need two things:
- A parameter enabling the user to choose a month
- A calculated field to take the chosen date value and keep the relevant time periods
Create a parameter, set as a Date Data type and either allow a list or set a range of date values.

For it to appear to the user they are selecting a month (they are actually selecting a date in that month), set the Display Format. To show Jan 20, for example, this is a Custom format of mmm yy.

Next hook up a calculated field to use this parameter selection.
A year on year calculation needs both the chosen month and the same month last year. Therefore, create a Tableau calculated field that keeps both months.
Create a simple Boolean calculation. This formula returns True for all Order Dates in the same month/year as in the parameter OR for all order dates in the same month last year.
DATETRUNC('month',[Month Parameter]) = DATETRUNC('month',[Order Date]) OR DATETRUNC('month',DATEADD('year',-1,[Month Parameter])) = DATETRUNC('month',[Order Date])

Put that calculated field to the Filter shelf and set to True.
Now you have all the data needed to display the numbers from the selected month and also show the YoY change.
Show this month, last month and the YoY change in Tableau
The calculation above shows the chosen month and the same month last year. To also show last month simply means expanding the calculated field.
Add an extra OR clause to also select the month before that chosen in the parameter.
DATETRUNC('month',[Month Parameter]) = DATETRUNC('month',[Order Date]) OR DATETRUNC('month',DATEADD('year',-1,[Month Parameter])) = DATETRUNC('month',[Order Date])
OR DATETRUNC('month',DATEADD('month',-1,[Month Parameter])) = DATETRUNC('month',[Order Date])

Smart use of date functions in the calculated field gives immense flexibility to filter dates with a parameter.
An example using a Tableau parameter to show the chosen month and the Previous month
Build a month parameter, as above, remembering to make it a Date data type with the custom Display format.
Next, create the calculated field telling Tableau what dates we want, using the value selected by the user.
Remember the parameter only actually selects the 1st of the selected month but the user thinks they’re selecting the entire month.
Therefore, our calculated field should return the entire month.
We also need to select the entire previous month for the hypothetical month on month comparison.
This calculated field will go on the Filters shelf.

Note: The date field name is [Day] in the example dataset.
Now we have all of our fields you can construct a worksheet. Right click on the parameter DateSelector and ‘Show Parameter Control’
Drag the DateFilter into the Filter section and set the value to True.
Then pull in the other data you want to display in your report.
In my example, I have shown daily visit data comparing the selected month and the previous month.

The interactive version is below.