How to Create Parameters in Tableau (A Simple Guide)
What Is a Parameter in Tableau?
Parameters are among the most versatile and useful features in Tableau — especially following the 2020 addition of parameter dashboard actions. As with just about anything in Tableau, we can start small and work our way to greater complexity — Tableau parameters are no different.
Why Use Parameters in Tableau?
But before we start, you may be wondering What is a parameter in tableau, and why would we use one? Fantastic questions. A tableau parameter is similar to a calculated field in that it's not a part of the dataset — instead, the tableau developer creates it. It's also similar to a filter, in that an analytics consumer will usually see a Tableau parameter on a dashboard they can click to customize the view. It differs from a calculated field and a filter in that it gives us far more flexibility in its creation and its behavior once we deploy it.
Before we begin creating a parameter in Tableau, here are some of the most common uses of Tableau parameters:
- Creating a top x filter
- Changing the dimension or measure displayed in a chart
- Selecting a single value to highlight
How to Create a Parameter in Tableau
Creating parameters in Tableau begins the same way as creating a calculated field. Click on the drop-down arrow to the right of the search bar. Select Create Parameter. We’ll then presented see this widget. Let’s go through it.
Name: This will be the name of the parameter.
(Pro-tip — I like to start all my parameters with a prefix like “Para” or “@” so they are easier to identify.)
Data type: Where we select if this will be a float, integer, string (text) or date type.
Display format: Allows us to format the value (e.g., change it to a currency).
Current value: This is the default starting value.
Value when workbook opens: Here, the default is current value, and we won't interact with this in the beginner tutorial, but as we gain more experience with parameters, there are some useful features in here.
Allowable values: The default is all, which means any value that is a float (so all decimal numbers) are valid input. A List means that we, as the developer, give the user a predefined list of allowable values to pick from. Range (not available for text parameters) allows us to set a start and end point, and all values between the start and end points will be valid.
Creating a Parameter in Tableau
Let’s look at two examples of when and how to create a parameter in Tableau. I’ll be using superstore sales dataset, which is built into Tableau. The first example is to make a dynamic target that a user can control to quickly see which dimensions fall above or below the target.
Before creating the parameter, let’s build a quick chart by adding Subcategory onto Columns and Sales onto Rows. Now for the parameter, let's follow these steps.
- Click the arrow next to the field search bar, and select Create Parameter.
- Name the parameter “Para Subcategory Target.”
- Change the data type to Integer.
- Change the current value to 5,000.
- Click OK.
When we click OK, a new section in the calculated field pane appears, named “Parameters.” In that list, we should see the Para Subcategory Target.
If we right-click on the parameter and select Show Parameter, the parameter control section appears on the left. It will produce a box that looks similar to the filter, with the title “Para Subcategory Target” and the value 5000.
Parameters on their own aren't helpful, so we must always take the second step of adding them either to our visualization or to a calculated field. For example, if you type 6000 into the parameter control, nothing will change in our bar chart. Let’s add this parameter to the chart.
- At the top of the field list there’s an option to change the pane to “Analytics.”
- In the Analytics pane, drag a reference line onto the chart.
- For Value select from parameter and pick the Para Subcategory Target.
- Click fill below, and select red.
With this, we have a dynamic target, and we can easily see which subcategories are underperforming.
Another common use case for a parameter is as a dynamic dimension swapper — a parameter that will change the dimension in the chart based on the user input. Let’s create a second parameter. This one will be called “Para Dimension Swap.”
- For this second parameter, set the type to String.
- Make it a List.
- In the list, enter the following, each on its own line: Subcategory, Region, State.
- Click OK.
- Create a Calculated Field like the following:
We can now take our new calculated field and drag it on top of the Subcatergory dimension in our chart. If we right-click our Para Dimension Swap parameter and click Show Parameter, we can let the data consumer choose how they view this chart. And, of course, with the original parameter still there, we can also adjust the target reference line as we conduct our analysis.
Using Tableau Parameters
We've just explored two introductory examples for implementing Tableau parameters, but the use cases are endless. Mastering Tableau parameters can revolutionize the Tableau development experience and open up a world of possibilities as we create a tailored data consumption experience for our user.
As we gain experience with parameters, we can try concepts such as measure swapping, dimension highlighting, and sheet swapping. And once we’re feeling very confident, we can include parameter actions on a dashboard, which are incredibly powerful in their own regard.
Now, pull up your favorite workbook, and try out some parameters of your own!
If you’d like to learn more about this topic, check out Dataquest's interactive Data Visualization in Tableau Path that will help you master these skills in around 2 months.