Basics of Parameter

After covering a few things in Alteryx, we are back to Tableau! This post will be all about parameters. What is a parameter? The textbook Tableau definition of a parameter is a workbook variable such as a number, date, or string that can replace a constant value in a calculation, filter, or reference line. We'll explore the basics of a parameter and put it into action!


  1. Creating a Parameter

Let's say we wanted to create a parameter using the regional variable. Creating a parameter is straightforward, as shown below.

There are several things to keep in mind when creating a parameter.

  1. Make sure that the data type you are aligning to the parameter matches with the data type of the source field.

    • In this example, the 'Region' variable is a string, so I need to make sure the data type of my parameter will be a string.
  2. You can determine the parameter value that will show when a user first opens the dashboard by configuring the 'Current value' field.

  3. You can determine the parameter values by adjusting the 'Allowable values' section. In this example, I want to set a pre-determined list of values by pulling the values from the 'Region' field.

  4. When adding values from a field, you can either pull from a fixed list or decide to populate the parameter values when the workbook opens. The difference is that the latter option will populate the parameter from the latest version of the workbook everytime it opens. This can come in handy when a dataset you are dealing with gets updated periodically.

2. So What Does a Parameter Actually Do?

On the surface of things, nothing - until you put it into action.

Beneath the surface, the parameter actually populated each row in the data with  the value of the parameter. Let's take look at what I mean by showing regional
sales with the parameter column. I created a parameter column by using the  
following expression:

Parameter Calculated Field
Regional Sales Displaying Parameter

Notice that all the parameter did was populate each row in the view with the  value of the parameter. To action a parameter, we usually need to use it in a calculated field.

3. Using a Parameter as a Filter

For an example of this, I'm going to use the parameter as a filter by creating a calculated field.

Regional Parameter Filter

Let's stick this field into rows and see what this does to the view.

As I toggle through the parameter, the '# Regional Parameter Filter' calculated field checks if the parameter, signified by '# Parameter', equals the 'Region' field. If it does, it returns the Region. If it does not, it returns 'Other.'

Filtering the view using parameters can allow you to adjust the view without filtering the underlying data. Let's see what I mean by removing 'Region' and '# Parameter' from the view.

As I toggle through the parameter, the '# Regional Parameter Filter' calculated field checks if the parameter, signified by '# Parameter', equals the 'Region' field. If it does, it returns the Region. If it does not, it returns 'Other.'

Filtering the view using parameters can allow you to adjust the view without filtering the underlying data. Let's see what I mean by removing 'Region' and '# Parameter' from the view.

As a toggle through the parameter, the selected region's sales is returned, while the non-selected regions are subsumed under 'Other.'

What if you wanted take this one step further and allow the user to look at total sales for all regions?

4. Adding a Custom Parameter Value

To do this, you will have to add a 'dummy' variable. Let's create one, calling it 'None Selected.'

None Selected Dummy Variable

Stick the 'None Selected' variable into rows. You'll see each row carries the variable.

Dummy Variable

Now, let's add 'None Selected' as an option in our parameter. Please note that parameters are case sensitive.

Adding a Custom Value to the Parameter

Next, let's re-word our '# Regional Parameter Filter' to include 'None Selected' as an option.

Re-Worded Expression To Include 'None Selected'

Let's see what this new calculated field does to our view.

Final Parameter Settings

Everything acts the same until we select 'None Selected' in our parameter. According to our re-worded expression, Tableau checks if the parameter equals 'None Selected.' If it does, it returns the 'None Selected' field. Because every region is included in the 'None Selected' field, Tableau aggregates the sales of all regions and returns the total sales.

Hope this helped break down the inner mechanisms of parameters!

Author:
Charles Yi
Powered by The Information Lab
1st Floor, 25 Watling Street, London, EC4M 9BR
Subscribe
to our Newsletter
Get the lastest news about The Data School and application tips
Subscribe now
© 2024 The Information Lab