## Week 3: Parameters in Tableau | DS23

by Auguste Navickyte

Last week I spent quite some to get my head around parameters in Tableau. I needed to write down the steps from every parameter exercise we did during the training to understand how they work - but once you do, it becomes an easy concept.

What is a parameter? A parameter is a value that can be changed by the user whilst they are interacting with the visualisation, i.e. the view does not have a constant value. In other words, parameters enable the users to control the visualisation. How do we incorporate them in our visualisations? In very simple terms, there are two main steps:

1. Create the parameter

2. Use the parameter in a calculated field, filter, reference line or set

Where do you create parameters and calculated fields in Tableau? Find a tiny upside-down triangle on your left hand side of the workbook, next to Dimensions. If you click on it, two first options will be Create Calculated Field and Create Parameter (see below).

As I think examples work the best to understand such concepts, let’s look at the WOW (Workout Wednesday) challenge from week 38. It contains four filters at the bottom which have been constructed thanks to the parameters. I have focused on these filters and built a similar dashboard. Below, I present the steps of how to get each filter in your own Tableau dashboard.

### Slice by

This filter allows to “slice” the data based on manufacturer, product name, customer or subcategory (or whatever else you prefer based on your own data). To achieve this, follow these steps:

1. Create a parameter with a list containing the four meters (manufacturer, product name, customer and subcategory) (see 1 parameter below)

2. Create a calculated field:

CASE [1 parameter]

WHEN "Manufacturer" THEN [Manufacturer]

WHEN "Product name" THEN [Product Name]

WHEN "Customer" THEN [Customer Name]

WHEN "Subcategory" THEN [Sub-Category]

END

3. From left hand side, add the calculation to Detail

4. From left hand side, select to Show Parameter

### Separate Segments

This filter allows you to choose whether you want your view to be separated based on different segments (Home Office, Corporate, Consumer) or not. To get to this, follow these steps:

1. Create a parameter with values 0 (no segments) and 1 (all segments) (see 2 parameter below)

2. Create a calculated field:

CASE [2 parameter]

WHEN '0' THEN "All segments"

WHEN '1' THEN [Segment]

END

3. From left hand side, add the calculation to Rows and Detail

4. From left hand side, select to Show Parameter

### Separate Years

This one lets you separate the view based on years if you wish - so it is a very similar example to the one above, except you need to put the calculation into columns and not rows.

1. Create a parameter with values 0 (all years) and 1 (separate years) (see 3 parameter below)

2. Create a calculated field:

CASE [3 parameter]

WHEN '0' THEN "All years"

WHEN '1' THEN DATENAME('year',[Order Date])

END

3. From left hand side, add the calculation to Columns and Detail

4. From left hand side, select to Show Parameter

### Reference Line

Finally, you can select if you want to see the reference line (average) or not.

1. Create a parameter with values 0 (no reference) and 1 (reference - average) (see 4 parameter below)

2. Create two calculated fields (for both axis):

1) For Y axis:

IF [4 parameter]=0 THEN NULL

ELSEIF [4 parameter]=1 THEN SUM([Profit])

END

2) For X axis:

IF [4 parameter]=0 THEN NULL

ELSEIF [4 parameter]=1 THEN SUM([Sales])

END

Pay attention that I am using SUM of profit / sales in this step.

3. From left hand side, select to Show Parameter and also add it to Detail

4. From left hand side, add both calculations to Detail

5. Add two reference lines through both axes by clicking on them and selecting Add Reference Line; use your created parameters in the Value field; and make sure you select Average (see Edit Reference Line, Band or Box below)

And there you have it - all four parameters in one place! If you are struggling to grasp the concept of parameters, I would suggest watching tutorials on YouTube and writing down the steps until you start noticing these steps yourself.

Auguste Navickyte

Wed 21 Jul 2021

Tue 20 Jul 2021

Tue 06 Jul 2021