Tableau Parameters are some of the most flexible, and frankly, most awesome features of Tableau. A Tableau parameter allows you or your end-user to change the content that appears in worksheets and dashboards. This can be something simple like a value or something much more advanced. Here we’ll cover several of the most commonly used examples of Tableau parameters.
Pre-defined Lists for Faster Filtering
As a general rule, Tableau parameters run faster in Tableau than Quick Filters. Every time a Quick Filter runs it pings your data source, which can slow you down. Tableau Parameters are retained in memory. So, if you have a list of values you want to use as a filter that you know isn’t going to change, or will change infrequently, use a Tableau parameter instead.
For example, let’s say you have regions: North, South, East, West, MidWest, and Pacific Rim. You know that these are always the regions. You have a Dimension in your data called Region. You could use the Region field as a Quick Filter. However, you could retype these values in a Tableau Parameter and use that as a filter instead and gain processing speed. The caveat here is, if your Dimension is going to change frequently, say for example, Customer Name, you don’t want to be reupdating your Tableau Parameter all the time. Quick Filters are dynamic, Tableau Parameters are static. It’s a limitation of Tableau.
To create the Tableau parameter:
- Right click anywhere in the data pane along the left and choose Create > Tableau Parameter.
- Give the Tableau Parameter a title.
- Change the Data Type to “String.”
- Change the radio button at the bottom for Allowable Values to “List.”
- Type in the values down below.
- Choose ok.
- Right click again and choose Create > Calculated Field. Name your Tableau parameter calculation (i.e. Region Filter).
- Drag the newly created Tableau parameter into the calculation window where your cursor is so that it reads [Region Parameter] = [Region] (or whatever names you’ve chosen).
- Choose ok and then drag your Tableau calculation parameter to the Filters shelf. Set the filter to show only True.
Tableau Top N Parameter
Filtering and sorting are two of the most used tools in any analyst’s toolkit. Often you want to see just the top 10 of something. But what if your audience has different needs? Maybe someone wants to see the top 20 or the bottom 20. A Tableau parameter allows you to do this.
- Let’s look at top Products by Order Quantity. Drag Product Name to rows and Order Quantity to columns.
- Now drag Product Name to the filter shelf.
- A filter box will appear with a number of tabs along the top. Each of those allows you flexibility in how you filter. For now, go to the Top tab.
- Choose “By Field.”
- To create the Tableau parameter, select “Create a new parameter” in the drop down where it says 10,
- Name your Tableau parameter “Top N Products.”
- Set your min and max values in the Tableau parameter – in this case let’s do 10 and 50. Set the step size to 5 (this is by how much each change increments upwards).
- Click ok and a small box with a slider will appear on the right of the Tableau parameter box. Use the slider to adjust the Tableau parameter. Then, explore how the Tableau parameter changes the viz.
Reference Line Parameter
As mentioned previously, the reference lines Tableau parameter can be a very beneficial way to highlight key information, show thresholds and targets, highlight outliers, etc. Parameterizing these in Tableau allows your end-user to see the data in relation to the targets or thresholds or reference points they want to see.
- On the same chart we just created using Tableau Parameters, right click on the axis and choose Add a Reference Line.
- To create the Tableau parameter, click the drop down arrow (where it says Sum(Order Quantity) and change that to “Create a New Parameter” in the Value section in the middle.
- Name this Tableau parameter “Number of Orders > N”
- Make it a range of values in the Allowable Values section.
- Set the min to 50 and the max to 700 on the Tableau Parameter
- Set the step size of the Tableau parameter to 20.
- Now play with the slider and see how many fall above the line.
Swapping Dimensions or Measures in a View
We now get into a more advanced use of Tableau parameters, but one that is extremely useful. Say you have a well-formatted, insightful chart. Rather than recreate the same chart for six different metrics, you’d like your user to be able to see whatever they want to see with just 1 click.
- Create a new worksheet at the bottom.
- Right click in the data pane and create a new Tableau parameter.
- Name this Tableau parameter as “Choose Dimension.”
- Change the Data Type on the Tableau Parameter to a String.
- Set the Allowable Values to a List.
- Edit the Tableau parameter. In the window down below, type the following field names, one per line.
- Customer Segment
- Marketing Channel
- Product Category
- Product Sub-Category
- Product Name
- Click ok.
- Now right click and create a calculated field using a Case/When statement. Name it Choose Dimension Calc.
Case [Choose Dimension] When ‘Customer Segment’ then [Customer Segment] WHEN ‘Marketing Channel’ THEN [Marketing Channel] WHEN ‘Product Category’ THEN [Product Category] WHEN ‘Product Sub-category’ THEN [Product Sub-Category] WHEN ‘Product Name’ THEN [Product Name] END
- Note the following:
- Capitalization doesn’t matter in the function portions in blue.
- You need the apostrophe marks around the actual text shown in your Tableau parameter
- You can drag in your orange Dimension fields from the data pane.
- You must close the Tableau parameter with an end statement.
- If you are used to writing SQL, the case statement is obviously something you are familiar with. Note that Case syntax in Tableau is slightly different. It’s Case [Field] then your When conditions.
- Bring this calculation to the Rows shelf and Number of Records to the Columns shelf.
- Right click on the Tableau parameter you created at the bottom of the data pane and choose “Show Parameter Control.”
- Click the Sort Descending icon on the Tableau parameter.
- Now select different drop downs from the Choose Dimension parameter and see how the chart changes.
You can use this Tableau parameter technique to swap out dimensions, swap out measures, swap out headers on your axes in a chart, and change the title. This gives you almost infinite flexibility in how you present and share information.
Swapping Dimensions or Measures Examples
To illustrate just one more example of this Tableau parameter technique:
- Double click the title and name it “Orders by .” (Be sure to include the space after “by”).
- Then click the Insert drop down menu at the right of the Tableau parameter menu.
- Select your [Parameters.Choose Dimension] field. Click ok
- Now change the Tableau parameter values and see how it changes your title.
Tableau Parameters What If Analysis
Allowing users to perform a “what if” analysis can be an extremely effective way to motivate action. For example, if you highlight your company’s current state, and give them the ability to change some assumptions and values and see where you could end up, people want to make that a reality.
Let’s say we wanted to see the average price per Ship Mode.
- On a new tab, drag Sales and Order Quantity to the columns shelf. They’ll both default to Sum, which is what we want.
- Drag Ship Mode to rows.
- Create a calculated field showing sum([Sales])/sum([Order Quantity]).
- Name this Avg. Price and drag it to the right of the other two pills on the columns shelf.
- Turn on labels for each.
- Now click on the pill for Avg. Price and then click the Sort Desc icon.
- Now create a new Tableau parameter entitled What If Price.
- Set the Data Type to Float. Set the Min value to 0 and the Step Size to 10. Uncheck the Max value (this will allow your end user to set the number to whatever they want).
- Next, create a new calculated field and name this What If Revenue.
- Type in the following formula: ([Avg. Price]+[What If Price])*SUM([Order Quantity]) (There are duplicate order IDs in the data).
- This formula takes the average price and allows your end user to add an amount to the average price. Then you multiply the new price by the number of instances of that to determine the overall impact on revenue.
- Add the What If Revenue pill to the right of the other pills on the columns shelf.
- If the “What If” Tableau parameter box does not appear, go down to the Parameters section at the bottom left, find the Tableau parameter, right click it and choose “Show Parameter Control.”
- Finally, create a new calculation entitled Forecasted Revenue Increase using the following formula: [What If Revenue]-SUM([Sales]). Drag that to the columns shelf as well.
- Drag the same calculation to the color shelf on the segment under the marks card that is labeled AGG(What If…).
- This will convert all the other bars to a gray color and provide a default blue sequential color scheme on the last bars in the chart.
- Click the down arrow on the legend icon at the top right. Choose Edit Colors.
- Change the color to Orange-Blue Light Diverging. Set it to Stepped Color with 4 steps, and check the Reversed box.
- Now, look at the change in the forecasted revenue.
Finance wants to be able to have more control of how they look at the numbers. We’ll use Tableau parameters to give them this flexibility.
Practicing How to Use Tableau Parameters
- Go to the tab labeled “Best Customers.”
- If you don’t have it, bring Customer Name to Rows and Profit to Columns. Color by Profit. Sort Desc.
- Right click on the Measures pane and Create a Tableau Parameter.
- Title your Tableau Parameter “Top N Most Profitable Customers.”
- Set the Tableau parameter’s Data Type to Integer and set the Allowable Values to Range.
- Set the range from 1 to 50, with a step size of 2. Click ok.
- Now right click on the Tableau parameters at the bottom left and choose “Show Parameter Control.”
- Create a new calculated field entitled “Index.” In the formula window, type Index().
- We didn’t cover this much above but it works very similarly to the Rank calculations. Since we’ve already got customers sorted by profit in descending order, bringing out the Index calc will show the rank of each customer with 1 being the most profitable.
- Bring this out to the Rows shelf. The Tableau parameterS will automatically start as continuous and come after Customer Name.
- Click on the down arrow and set it to Discrete. Now move it before Customer Name.
- Create a new calculated field entitled “Top Customers.” Type the following formula:
[Index]<=[Top N Most Profitable Customers]
- This Tableau parameter will find the rank and show everyone before that and up to it.
- You can find the fields in your Tableau parameter date pane and just drag them into the calculation editor.
- Bring this new Top Customers calculation to the Filter shelf. Set it to True.
- If you don’t want to see the actual customer rank, click on the down arrow on that pill and uncheck “Show Header.”
- Move the slider around to see how the view changes.
If you have the Customer Profitability Overview Dashboard from Day 2, go to that dashboard and continue on for the rest of the steps in this exercise. If you do not have that dashboard, proceed to the next section of the book as you will need it for steps 15-20. However, no further practice exercises will depend on this dashboard, so if you do not have it, it will not halt your progress.
- Set your dashboard title to left aligned.
- Move the Customer Segment quick filter over towards the middle.
- Click on your Best Customers chart so that it is selected.
- Now go up to the Analysis menu at the top, Tableau Parameters > Top N Most…
- Set the Tableau Parameter to Floating by clicking the down arrow and position it next to the Customer Segment quick filter.
- Now click the down arrow on the Tableau parameter and change it from a Slider to a Type in box. Determine which of the two types you like most and set it to that.
There is more to learn about Tableau Parameters and the best ways you can utilize them for your data views and analysis. If improvement in Tableau usage and data analysis is what you are looking for, check out our Tableau Training that is available for both individuals and corporations.