Tableau Parameter Modification Using Calculated Fields and Filters with Conditions

Working on a Tableau project recently, we discovered a bug regarding Parameters.  The base Dashboard had a Parameter for Year and Quarter.  Each populated based on a list:



Looking through the code, the Year filter was pointing to the incorrect database field from Salesforce.  Thus, when the Parameters changed, the reports displayed incorrect data.

A Calculated Field set the Year field to the passed in Parameter:

In order to change the Parameters, I located the correct field to filter on.  Then created a Calculated Field to obtain the Year as follows:

Then added the new Calculated Field to the Filters, opened and under "Condition" added the following logic to filter the data set where the Year part = the passed in Parameter "Year":

For the Quarter field, very similar.  Created a new Calculated Field for Quarter, to obtain the Quarter fragment of the date field:

Next, add new Calculated Field to the Filters pane, open to "Condition" and add the following logic:

Essentially, it strips out the "Q" character from Q1, Q2, Q3, Q4 passed in value from Parameter [Quarter 1] which the user selects, converts to an Integer, and filters the Quarter date field where the Quarter is less than or equal to the Parameter value minus the "Q".

So if user selects Q3, strip out the "Q" resulting in 3 as Int, and filter date Quarter field for 1, 2 or 3 since that is equal to or less than 3.  It excludes Quarter 4 because 4 is higher than 3.

And these code modifications resulting in accurate results in Tableau Dashboard when user changes either the [Year] or [Quarter 1] parameters.

Hope that helps in your Tableau development.  Thanks for reading~!

Bloom Consulting Since Year 2000