2
votes

Is there a way to set dynamic default values for filters in Tableau?

Example: For Date filter set the value to previous month.

I know that default value for filters can be set as selecting a specific value before publishing the workbook.

There is an option to set default value to current date but I need it for previous month.

Let me know if need more information.

3

3 Answers

1
votes

You most likely need a filter using a calculated field. This can be achieved either by a fixed LOD expression or by using a table calculation.

My recommendation would be to filter the data at the extract level. So you would bring into Tableau only the data you need to work with.

I wrote an article where we bumped into a similar issue: https://canonicalized.com/tableau-dashboard-performance-optimization-case-study/?section=extracts (search for "Step 1: filter incomplete months" if you can't find it)

This is the LOD expression I used to filter the data for the latest month if it's incomplete:

{FIXED MONTH([Date]), YEAR([Date]): MAX([Date]) < MAX(datetrunc('month',dateadd('month',1,[Date]))-1)}
0
votes

Use a relative date filter. Right-click on the date dimension field and drag it onto the Filter shelf. Then choose the Relative Date option. This opens the filtering dialog box, choose Previous month on the Months tab. Then, when you publish the workbook, the default value will be what you saved in the workbook.

See the online help document for images and detailed step-by-step instructions. https://onlinehelp.tableau.com/current/pro/desktop/en-us/qs_relative_dates.html

0
votes

We can have this with Parameter and with one calculated field.

  1. Create a Parameter using Date column. Create parameter

  2. Create Calculated field – When you open the workbook, default it will be set to prior month (Based on your requirement you can change the formula to previous month of last year).

{ FIXED : MAX(DATEADD('month',-1,[ Snapshot Date]))} Calculated field

  1. Call this calculated field in Parameter – Value when workbook Opens :(Prior Month-Cal). add as current value

  2. Use parameter to filter the months (list of months and also default it will be prior month). Filter Prompt looks like