top of page
Search

# Tableau Tips: Parameters - Calculated Field

Updated: Aug 18, 2021

When we introduced parameters, we alluded how powerful this feature is in dashboard development. Therefore, in this second case study on application of parameters, we’ll demonstrate the power of using Tableau parameters with calculated fields.

In this case, we’ll be working with data on Type of Roofing Structures in Kenya, here is a snapshot of the data.

But before we get working with the data, allow me to mention that another alternative to what we are going to demonstrate is using Tableau prep to shape our data before visualizing it. While we know, how shaping our data can help us accomplish our work easily, for this case we won’t take that route, instead we would like to tap the power of parameters with calculated fields to create our viz.

But first, some hints;

Before we begin working with calculated fields editor, it’s good note that Tableau color codes functions in different ways, here is a sample;

### Using parameters with calculated fields

Using data on Type of Roofing Structures in Kenya, we would like to rank County’s by the type of roofing structure. Like, we explained at the beginning of this article, we don’t want to shape our data in Tableau prep, or use pivot feature to shape it in Tableau desktop. Our goal is to use Parameters to help us decide which measure field (Roofing structure for this case) to use in our view.

Our final view should resemble this one, but of course with some difference;

The difference between this view and what we expect in our final view is, our final view will be more dynamic, with parameters we will be able to choose measure field for computing our viz.

Here are the steps to guide us;

1. Creating a parameter

2. Show parameter control.

3. Use parameter in calculation field.

4. Use calculation field in the view.

### Creating Parameter

For this article, we will only use five measure fields (Tiles, Grass, Concrete, Mud/Dung & Makuti), however it’s good to note the same technique can be replicated in all other measure fields.

### Show parameter control

At the bottom of the data pane window, right click on the parameter we’ve created ‘Select Roofing Type’ > Show Parameter Control.

Note: Our parameter will now appear on the top right corner of the window, ready for use.

### Use parameter in calculation field

Open calculated field editor by right clicking on any field > Create > Calculated Field…

Rename it 'Parameter values' and fill it as shown below.

Note: This calculation is case sensitive and therefore you should ensure your parameter fields match with what you’ve used in the calculated field. Aggregation used in the calculated field can be any function that will suite your objective.

### Use calculation field in the view

Let’s build our viz;

• Drag dimension ‘County’ to the rows shelf.

• Drag measure field we’ve created ‘Parameter values’ to the columns shelf.

• Sort County in descending order by Parameter values.

• Show labels.

• Add parameter title by double clicking on the title to edit the title, clear the title editor and insert ‘Parameters. Select Roofing Type’.

Final view;

Note: In this view, using parameters and calculated fields we can now chose which measure field we would like to compute our view with.

Other, capabilities like displaying the top/bottom N members can be added to eliminate the scrollbars or help fit our viz in different screens.

### What next?

Our next article on application of parameters, we’ll learn how to use parameters with reference lines. Stay tuned to explore the third use case of parameters.

To receive more of Tableau tips and tricks, kindly join our mailing list by subscribing below.

Thank you for reading.