Skip to main content

Jim Dehner 

 Tableau Visionary – HoF

Tableau How to’s,  Use Cases, and Forums Questions

Hey #DataFam

Let’s Talk

Open for

Post Links

Do you use Parameters? Why not?  They are the way to change  views, customize a calculation, create sets or filters, and zoom into maps. 

Parameters are VALUES that the user can input or change by selecting from a drop-down menu, keying in directly, or with a Parameter Action.  That value can be used to create a filter or a set, in a calculation, within a Boolean Trigger for DZV, to create filters across blended data sets, and much more. 

There are also 3 rules you need to remember about parameter values:

  • are Global – the parameter value is the same throughout the entire workbook
  • are singular – only one value at a time
  • values only change manually or with a parameter action

Let's see how to set them up and then explore some use cases.

1-Setup –

The easiest way to preload the parameter drop-down list is directly from the Dimension in the data frame. Right-click to open the dimension pill and select Create Parameter.  Tableau will create the parameter, give it an appropriate name, and load it with the dimension values:

Alternatively, you can create the parameter from the drop-down in the data frame, and a setup window opens:

Within the setup window, you select from the available types of parameters, driven by how the data is cast. 

And then set up the parameter in detail – a few best practices:

  • Always add a Name (you will be glad you did when you have many in a workbook)
  • Select the Data Type next – the Type must match the comparable data in the dataset – i.e., Integers match Integers, Dates to real date, String to String, etc.
  • Planning to use a Dynamic parameter? – then select the appropriate when open and load from values
  • MOST important – the VALUE  is used in the matching calculation – the DISPLAY is what appears in the Drop-Down – they don’t have to be the same, and it is often an advantage when they are not
 

You can also load the parameter list directly by keying in values or pasting them from the clipboard ( Simple left column for VALUE and right column for DISPLAY)

2  The Basics- Using Parameter Values in Filters and Sets

Parameter values can be used to create filters either through calculations or embedded in the setup of another function. 

Setting the value of a Dimension to the value of a parameter creates a Boolean (T/F) placed on the filter shelf (the Dimension is then filtered by the parameter.  I know that sounds geeky, but it will help you when debugging your worksheets.

Here, selecting Office Supplies in the parameter and True in Boolean “filters” the data as shown:

Filters remove data from the data table, and Sets group the data into IN and OUT categories. No data is lost –  Parameter values can be used to define the groupings.  From the Set Condition Tab, select Condition and use the same formula we did for the Boolean above. 

Selecting Office Supplies in the parameter – creates an IN – all the records containing Office Supplies and an OUT Group – records that do not contain Office Supplies>

The parameter value is the same, but the results are very different.

Let's have a little fun before moving on.  If we can use the parameter value to create a Boolean that filters for the True value, we can also filter for the False values.

And now, Office Supplies are filtered out of the data table.

With a small change to the Calculated Field, we also have the option to select a single value or All values.

Add All to the parameter list (key it in)

And use this calculation as a T/F filter

And the same parameter can be used to show all Dimension values

2.5 Filtering across Blended Datasets

If you are forced to use Blended Data, you probably have found that you can't filter across the combined data.  Frustrating, I know, but that is a function of the Order of Operations (see Order of Operations).  If you are filtering a single dimension, you can use a parameter as a workaround.  Parameters are global, so the value is the same throughout the workbook.  You will need to create a separate filter in each data set based on the parameter value:

Here, I have life expectancy and population data from one file blended with CO2 emission data from another.  I need to filter the Country across the 2 data sets

The solution is to create a parameter:

Connect the datasets on Country

In the CO2 dataset, I use the parameter to color the country-related trend in blue, while setting all others to gray.

if [Country Parameter] = [Country] then "Blue" else "Gray" end

There is a simple country filter in the world indicator data set

And a parameter action resets the parameter action based on a selection from the map

And this is the result:

OK, if Parameters are just values that a user can change from the Viz, is there an easier, more user-friendly way than using drop-downs? 

Sure –  Parameter Actions change the parameter value based on a selection from the worksheet (or dashboard) – they are easy to set up. From the top ribbon, select Actions (on Worksheet or Dashboard). Assign a Name and the Source Sheet – here a Value Picker to change the Category – then the Parameter to be changed –

Selecting “Office Supplies” on the value picker will change the parameter value and all filters, sets, or calculations dependent on the value will change accordingly

Look for how they are used in the following examples

3 Dates and Parameters

Frequently, users want to change the date level.  Just add a parameter for the date level:

Note: the VALUE must be in the syntax used in the date function – lower case singular

Then use the parameter in a calculated field:

DATETRUNC([3 Select Date Level],[Order Date])

Place the date on Columns as an exact – continuous date –

 
 

The user can select the level from the parameter

Need discrete dates? – simply change the date format to Exact – Discrete  

The most frequent question I hear is how to do YTD and YoY analyses (see 5 Ways to do YoY and YTD ) 

  – Using a parameter to select an end date makes it easy –

Use a real date for the parameter (Not Text). Accept All values and set up an LOD {max(today())}  as the when open value to default to Today’s date

The formula for the current YTD checks for dates in the same year and before the parameter date

{ FIXED [Category] :sum(

If datetrunc('year',[Order Date]) = datetrunc('year',[3 Select end date ])

And datetrunc('day',[Order Date]) <= datetrunc('day',[3 Select end date ])

then [Sales]   end)}

The Prior YTD just decrements the parameter value by one year:

{ FIXED [Category]:sum(

If datetrunc('year',[Order Date]) = datetrunc('year',dateadd('year',-1,[3 Select end date ]))

And datetrunc('day',[Order Date]) <= datetrunc('day',dateadd('year',-1,[3 Select end date ]))

then [Sales]  end )}

and the results

 

4 Dynamic Zone Visibility – Driven by Parameters

 

One of my favorite features is DZV – you know –  dynamically changing the view by making containers, worksheets, legends, or any other thing appear or disappear on a dashboard.  Parameters are often used to make that happen,

DZV uses a Boolean Trigger (that’s just a True–False statement) to make views appear.  (see Dynamic Zone Visibility – Use Cases)

In this dashboard:

We want to make the Bars, Lines, or Text disappear based on the parameter value

Set up a simple string (text) parameter –

Then 3 Boolean Triggers –

One for bars :    [4 view type] = "Bars"

One for Lines:  [4 view type] = "Lines"

One for Text:  [4 view type] = "Text" 

We want to see the color legend for Bars and Lines, but not for Text, so there is a 4th Boolean.

[4 view type] in ("Bars", "Lines")

The DZV control is on the Layout tab for the Dashboard.  For each sheet, turn on DZV and set the trigger to the appropriate trigger

And the user selects the view to see using the parameter

 

4.5 Parameter-Driven Measures

Have you ever wanted to give the viewer an easy way to switch between different Measures without changing the view? 

Start by setting up a String Parameter with the measure names you need:

Now add a Case statement driven by the Parameter:

CASE  [4.5 Select Measure Name]

When "Sales" then Sum([Sales])

When "Quantity" then Sum([Quantity])

When "Profit Ratio" then SUM([Profit])/SUM([Sales])  end

Note: Sales and Quantity need to be aggregated to the same level as Profit Ratio

And create the worksheet based on the calculation:

Changing the parameter changes the measure in the bar chart

5 Spatial Parameters – New in version 2024.3

Spatial parameters are great – they return the longitude and latitude of a single point, a collection of points, or a spatial shape. But you must have uploaded spatial data!!! – (i.e., the data contains longs, and lats, and a spatial shape designation – see zzz for more on spatial files.

We will start with a point file of all the Starbucks locations in NYC – we are only concerned with 3 fields – Long, Lat, and  Location.

Convert the longs and lats to a spatial point using the spatial function Makepoint.

MAKEPOINT([Latitude],[Longitude])

Then plot the resulting points on a map

That’s a lot of Starbucks locations!  The goal is to select a single location using a spatial parameter and then find all the Starbucks locations within a circle (the radius controlled by another parameter)

Let's add the spatial parameter –  Allow All Value. When there is no point selected, the parameter value should be “Empty” – for now, and key in Empty for the current value –

Next, add a floating-point number parameter to change the circle radius

Now we need to convert the Values the spatial parameter returns (long and lat) to a spatial point –

We create a circle around the selected location with a spatial formula “Buffer”

BUFFER([5.5 Convert SP to Spatial Field],[5.5 Circle radius close to Selected Starbucks],'km')

And then find the points within the circle with this

INTERSECTS([5.5 Circle Around Seleted SB location],[5.5 MakePoints from SB Long – Lat])

We are almost ready to create our Dashboard – just need a list of all the Starbucks in NYC:

Drag the calculation for the locations in the circle to the filter shelf and set it to True (currently, the parameter is Empty, so it would filter out all the locations

And add a parameter action to fill the spatial parameter  – we fill the spatial parameter on “Select” from the Makepoint from the SB Long-Lat field in the SB location data set.  Also, when clearing the section, return the parameter value to Empty

And when a single location is selected, the list filters and the locations in the circle change to light yellow

Spatial Parameters can also select an entire spatial shape defined in the data.  In a separate spatial file (.shp), the NYC subway lines are  Linestring –

The shape file will bring in all the other geometry needed to create the subway map

Now, add a spatial parameter to select an individual subway line:

Create a buffer around the points that make up the selected subway line

buffer([5.5 Select NYS SW line],[5 Radius around selected points],"mi") 

and a filter for the intersection of the subway line and Starbucks locations

INTERSECTS([5.5 Select NYS SW line],[5.5 MakePoints from SB Long – Lat])

And build out the dashboard

And add 2 parameter actions:

For the selected subway line :

And one to select a Starbucks location

Note- the 2 datasets are not connected.  Parameters are global, so we can select locations from one dataset and use them in another.  The first spatial parameter collects all the longs and lats from the selected subway line worksheet.  They are used on the Starbucks worksheet to find the intersection with buffered Starbucks locations. Finally, the second spatial parameter is used to find all the locations within the radius on the Starbucks worksheets.

That’s a lot – but it is only the beginning of what can be done with parameters.  Now get out there and use them in your next viz!!

The workbook used here can be found at Link to Parameter WB

See the video at Parameter Video

Leave a Reply

Your email address will not be published. Required fields are marked *