Tableau Deep Dives are a loose collection of mini-series designed to give you an in-depth look into various features of Tableau Software.
In this Tableau Deep Dive, I’m going to dig into parameters and some of the different places where you can use them. Parameters are values that users can change when interacting with a view. They add versatility to your visualizations.
Within Tableau, wherever you are entering a constant value, there’s a great chance you can use a parameter instead. There are four standard use cases for parameters. They are filters, bins, reference lines and calculated fields. I say reference lines, but really they’re applicable to quite a few things in the Analytics tab/menu.
For this Deep Dive, we’re going to cover as much as possible on parameters. Here’s our article schedule:
- Part 1: Parameter Overview
- Part 2: Parameter Properties
- Part 3: Filtering – Top N
- Part 4: Calculated Fields
- Part 5: Filtering – Across Data Sources
- Part 6: Histogram Bins
- Part 7: Reference Lines
Let’s get started.
Parameter Overview
To start this discussion, let’s talk about the attributes of a parameter. Your users can choose and change the value of the parameter similar in functionality and appearance to a filter. Parameter controls are interactive and allow the report consumer to affect your visualization. Secondly, all of the values within your parameter must have a consistent data type. For instance, if one of your values is a string, then they all need to be of the string data type.
Next, parameters are static. You can populate the list or range of values within a parameter by using a field from your data source, but it will not update the values even if your field values changes in your data source. It will be static to the moment the parameter is created.
Parameter values can be:
- Defined by the Desktop user
- Entered as an input by the report consumer
- Populated with the values of a field from the data source
Dynamic parameters are on the list of things Tableau is considering for future versions, but as of 9.3 we are not there yet. Our very own Derrick Austin has written an article on a workaround for a dynamic parameter. Next, parameters are data source agnostic. This is important when we talk about filtering across views using different data sources on the same dashboard (see Step 4 below).
Finally, you can use parameters in your custom SQL. Be careful though, because this can significantly impact the performance of your viz as explained here by Anthony Ball in our Tableau Performance Checklist series.
Using Your Parameter
There are four steps to creating and using a parameter. These four steps don’t necessarily need to be in a specific order. What is important is that you eventually do all four steps:
- Build Your Parameter: There are a couple of ways to build a parameter. The most direct is to right-click on the white space in your data pane and select Create Parameter. When you do, you’ll get the Create Parameter window as described above.
- Show Parameter Control: Right-click on the desired parameter in your Parameters section of your Data pane. Select Show Parameter Control, and your parameter control will appear in your visualization just like a filter control:
- Use Your Parameter in Calculation: There are a lot of different ways to use parameters. Keep in mind the four standard use cases that we outlined at the top of the article (filters, bins, reference lines, calculated fields). We’ll cover this in subsequent articles in this series, but whenever you are looking at entering a constant, Tableau will likely give you an option like this:
- Use Your Calculation in Your View: The last piece is using the calculation within your view. For instance, if your parameter is a top # of a list, then you’d use it in a filter. If your parameter was different bin sizes, you’d use it in a histogram.
I really want to stress that you do not have to do these in a particular order, but you do need to do all four steps for successful use of parameters. In fact, in our examples later in this series, we’ll mix up the order multiple times.
Performance Tips
The greatest dashboard ever seen by the human race is absolutely worthless if it takes five minutes to load. Speed is essential, particularly in the era of high speed internet. Performance must be at the forefront of your mind when using parameters. What might work great in your local environment on Tableau Desktop could create a massive resource issue when deployed on Tableau Server with hundreds of concurrent users.
Row-Level Parameters
Remember from Step 1, there is an option when building a parameter to populate the list from a field. Doing this with a dimension that has a lot of different values can seriously impact your performance.
Let’s take an extreme example just to illustrate the point. I want to create a parameter that uses Customer Name to provide values for my list if values. My hypothetical company has seventy million customer names in our database. You can imagine how this might not only cause a delay with your dashboard but also crash your server as well.
To keep your server admins off of Prozac, avoid using fields with a large and varied membership to populate your parameters.
Parameters & Custom SQL
Did you know you can use a parameter inside of your custom SQL statement? This feature first appeared in Tableau 8. We caution people when they use custom SQL. Make sure you know what you’re doing, because you can break your workbook very quickly.
Tableau has its own query language that it uses to connect to the data source through a driver. When you write custom SQL, it’s included in Tableau’s query language as a subquery. Your query does not operate in a vacuum for this reason. You can have unintended consequences by not understanding the context around your SQL.
For parameters, the versatility of multiple values within a single variable can create performance issues all on its own in the SQL. Tableau caches the query to optimize performance, and if your user is changing values within the parameter, it’s possible that Tableau won’t have a cache for it. Try to limit your parameters inside of custom SQL use for frequently used parameters or parameters with a limited membership of values.
For more help on optimizing your parameter use within your worksheets, check out Workbook Tools for Tableau. There are two tools within the suite that will help significantly: the Performance Analyzer and the Best Practices Tool.
What’s Next?
I know that this is all conceptual until we actually go through a parameter example. The next topic we’ll cover in Part 2 is how to build a parameter by reviewing all of the parameter properties.
For the time being, let me know if you have any thoughts or questions on anything we’ve covered today. Looking forward to hearing from you!