Welcome to Part 2 of my tutorials on Tableau parameters, we will be building on our previous work from Part 1. In Part 2 we will be creating the following parameters:

 

  • Parameter 3 – Dynamic Measures – ‘Select a measure’ (string parameter)
  • Parameter 4 – Dynamic filter – ‘Product position’ (string parameter)
  • Parameter 5 – Reference Line Benchmark ‘Sales Benchmark’ (float parameter)

Alright let’s dive right back into it. Once again, you may watch each section separately or watch the full video at the end of this page. 

Parameter 3 - Dynamic Measures (string parameter)

We are going to create a dynamic measure selector so our bar chart can show us the total sales or the total sales volume, to do this we are going to create a parameter just as before.

  • Name it ‘Select a measure’.
  • Change it to string.
  • From ‘Allowable values’ we will select ‘list’.
  • Type ‘Total Sales’ into the values.
  • Then ‘Total Sales Volume’.
  • Click ‘okay’.

Once again, right click on the parameter and say ‘show parameter’, then click on parameter in the filter right side bar and change it to ‘Single value list’.

Now we test it and see nothing is working, so we need to create a calculated field. This can be done by clicking the little drop down by the search bar on the left panel as you did for creating a parameter. Click this, then click ‘Create calculated field’.

Rename it as ‘Measure Selected’ – and here we will use a ‘Case’ function’. Now, we can either drag, the ‘Select a measure parameter’ into the calculated field or we can type it out:


(CASE [Select a measure]
WHEN "Total Sales" THEN SUM([Sales])
WHEN "Total Sales Volume" THEN SUM([Sales Volume])
END).

Now let’s understand how this calculation works.

When it finds – in the parameter – the words ‘Total Sales’ then it will give us the sum of the sales and when it finds the ‘Total Sales Volume’ selected it will give us the sum of the sales volume. Let’s click ‘okay’

The next step is to drag our ‘Measure Selected’ calculation into our columns shelf – creating two bar charts side by side – and now -as we can see – that we have our total sales selected in the parameter it is matching our other bar chart for sum of sales and if we change our parameter to show ‘Total Sales Volume’ it shows us the total sales volume.

To test this further, let’s drag in ‘Sales volume’ into the columns shelf just to compare it and make sure it’s working. We can see that the values match. 

Since it is working, we can remove the other two measures from the columns shelf by right clicking and selecting ‘remove’, leaving us with only the ‘Measures selected’ in the columns shelf.

At this point, we want a new heading to show us what ‘measure’ we are viewing. So, we are going to drag the ‘Selected measure’ parameter to the top of the bar chart and we see a small dashed lined above there. Furthermore, when we drop the parameter there, we notice that now we have a new heading that matches the ‘measure’ we are viewing.

We don’t want the name of the parameter to show – just the ‘measure’, so let’s right click on the heading and ‘Hide the field labels for columns‘, so we only see ‘Total Sales Volume’, then on the bottom of the x-axis right click the axis title and untick the box ‘show header’. Finally, we have a dynamic axis label of ‘Total Sales’ or ‘Total Sales Volume’, depending on what we select on our parameter.

Parameter 4 - Dynamic filter (string parameter)

We’ll now work on the fourth parameter for this chart. Another string parameter, but this time we will create this with a slightly different method.

This parameter will be for product position. Product position has three categories, and we could create it in a similar way as we did before; however, that method can be monotonous and inefficient when we have multiple categories that we want from a dimension (categorical variable).

So, let’s begin.

So, let’s begin.

Firstly, we need to right click on ‘Product Position’

  • Choose ‘create’
  • Then ‘parameter’
  • Change the name to ‘Select Product Position’
  • Next, click ok.

You will have noticed that it has already selected the correct data type – string – and it has prepopulated the product positions -meaning we do not need to type this out manually.

This works for parameters that are created from dimensions that already have their own categories. It would not have worked for creating ‘Parameter 3’ for the ‘Total Sales’ and ‘Total Sales Volume’.

We now have our parameter: ‘Select Product Position’.

Right click on ‘Select Product Position’ parameter to the show parameter. Once again it will not work on its own, so we need to create a calculated field.

Select create a calculated field as we did before

  • Rename it as ‘Product Position Selected’,
  • then drag in the parameter ‘Select Product Position’,
  • type ‘=’
  • then drag ‘Product Position’ from the data pane to the calculated field,
  • Click ok.

What this calculation does is: it checks what the user has selected from the parameter and if that matches one of the values in ‘Product Position’ then it will be ‘true’ for the matching value and ‘false’ for the two unmatched values. So, when this field is used as a filter, then we can filter the ‘true’ values and those will correspond with the user’s selection.

Let’s drag this now on to the ‘Filters’ shelf. Select ‘true’ and deselect ‘false’.

Now, we can drag the parameter ‘Select Product Position’ to the y-axis and when we see a dotted line, we can drop it, just like when we created the ‘Select a measure’ heading.

  • Right click on the heading on the y-axis,
  • select ‘rotate label’,
  • then right click on the heading that says ‘Select Product Position’ and choose ‘Hide the Field Labels for Rows’.

Now, what we can see on the y-axis is the label of the exact product position selected by the parameter and the sub-categories that are in that position.

The axes titles dynamic and we will now edit the chart title to update as well.

After selecting edit the title, add ‘in the’ at the end and then drag in the parameter of select product position so now the title can tell us – dynamically- whether it is the Top or Bottom Sub-categories and the ‘N’ chosen is 3 or 5, or whatever is selected, it can also tell us what the product position is.

Let’s play around with it a bit and make sure everything is working. 

Since it’s all working let’s add some final formatting.

We can change the colour of the chart to a turquoise hue (or any colour you choose), then right click anywhere on the bar chart and select from the menu ‘Format’.

  • If you go to the last option which are the lines,
  • go to columns,
  • in the grid lines: select none to remove all grid lines for enhanced neatness,
  • next, on to the ‘Borders’ option,
  • click for sheet,
  • then remove row dividers by clicking on pane and select none,
  • finally, go to column divider click on pane and select none as well.

This really takes out a lot of the clutter to enhance the visualisation’s appeal and understanding.

Let’s now make this into a very minimalistic dashboard by clicking on the bottom add dashboard – where we added our sheet.  

Now let’s drag in our sheet from the left panel to the dashboard and resize this. 

Click presentation mode and bask in the final product of your efforts. Checking that all your parameters work the way you would expect.

Well done!

We’re not done yet!

Remember that I said I will be teaching five parameters?

Well, here’s the bonus.

Parameter 5 - Bonus - Creating a parameter with a reference line

For our fifth and final parameter we will use that copy of the chart I said to create earlier and create a bonus chart. We will see how to use a parameter with a reference line to create a dynamic benchmark line.

The base of my chart is the ‘Top/Bottom N Sub-categories by Sales’.

To begin creating the parameter, right click on the x-axis and select ‘add reference line’.

  • Under the heading ‘Line’, click the first dropdown next to ‘value’.
  • You will see the option for ‘create a new parameter’.
  • Click it and this will open up the same new parameter window as before.

Rename the parameter to be ‘Sales benchmark’.

The Data Type is already set to float – it chooses the data type based on the data on that axis.

  • In current value, type out one million.
  • Under allowable values select ‘Range’
  • Put a minimum of 1 and a maximum of 100 million.
  • Click ok

Finally, we can see we have a line for the sales benchmark and on the sales benchmark parameter on the right if we type in 15 million, notice the benchmark moves. This is a parameter with a reference line which also works with our ‘Top/Bottom’ filter.

In Summary

To recap this tutorial, we covered how to create 3 different parameters:

  • Parameter 3 – Dynamic Measures – ‘Select a measure’ (string parameter)
  • Parameter 4 – Dynamic filter – ‘Product position’ (string parameter)
  • Parameter 5 – Reference Line Benchmark ‘Sales Benchmark’ (float parameter)

We also created a calculated field with a ‘Case’ function, two dashboard parameter actions and we created reference lines. Now you can recap by watching the full video demonstration below.

I hope these Blogs have sparked the fire of visualisation within your heart and inspires you on your Tableau Visualisation journey to construct an interactive chart with myriad parameters that bring your dashboard to life. Remember the power of discovery– the power of interactivity that parameters enable. 

 

Reference to source of original data:
Data from Kaggle