Providing Self-Service Ad Hoc Analysis with Parameters in Tableau
Providing Self-Service Ad Hoc Analysis with Parameters
The tableau core design encourages discovery. It connects to a wide variety of data sources, and this is further extended through data blending from external sources.
ad hoc can be defined as follows:
“Concerned with a particular end or purpose, formed or used for specific or immediate problems or needs, fashioned from whatever is immediately available.”
Parameters allow those consuming reports to change the context of views with Quick-Filter-like controls. Report builders design parameters into views when the report is created in Tableau Desktop. Parameters, create a pathway for non-technical consumers to conduct ad hoc analysis by changing what and how facts and dimensions are displayed—within the boundaries of the designer’s intended usage. Concerns regarding the efficacy of self -service analysis are minimized because the report designer controls what changes are permitted.
Three ways Tableau facilitates ad hoc analysis are:
- Generating new data with forecasts
- Designing flexible views using parameters
- Changing or creating designs in Tableau Server
What Are Parameters?
Parameters are useful when you want to add interactivity and flexibility to your report, or to experiment with what-if scenarios.
Parameters are dynamic values that can replace constant values in calculations, filters, and reference lines. For example, you may create a calculated field that returns true if Sales is greater than $500,000 and otherwise return false. You can replace the constant value of “500000” in the formula with a parameter. Then, using the parameter control you can dynamically change the threshold in your calculation. Alternatively, you may have a filter to show the top 10 products by profit. You can replace the fixed value “10” in the filter to by a dynamic parameter so you can quickly look at the top 15, 20, and 30 products.
It allows users to alter the content of a formula or change a dimension or measure contained in the view. Parameters, create a powerful means for changing normally static values into dynamic entities that facilitate ad hoc discovery without the need for changing the design of the view.
How Can Parameters Be Used?
When you work with parameters, consider the following two things that are important in making them useful:
- They need to be used in calculations.
- The parameter control needs to be displayed so that viewers can interact with it.
The different ways parameters can be used is limited only by your imagination. Tableau provides some basic parameter controls by building them in different contexts that commonly benefit from the use of a variable. Creative report designers can dream up a myriad of other ways to use this powerful feature by building formula variables that control the facts in view , the dimensions that appear, or the length and granularity of time series data. Anywhere that you can place a field in Tableau Desktop is a potential repository for a parameter control.
- In Calculations : Parameters give you a way to dynamically modify values in a calculation. Rather than manually editing the calculation (and all dependent calculations), you can use a parameter. Then when you want to change the value, you open the parameter control, change the value, and all of the calculations that use that parameter are updated.
- In Filters :Parameters give you a way to dynamically modify values in a TopN filter. Rather than manually setting the number of values you want to show in the filter, you can use a parameter. Then when you want to change the value, you open the parameter control and the filter updates. For example, when creating a filter to show the Top 10 products based on total profit, you may want to use a parameter instead of the fixed “10” value. That way, you can then quickly update the filter to show the top 10, 20, or 30 products.
- In Reference Lines :Parameters give you a way to dynamically modify a reference line. For example, instead of showing a reference line at a fixed location on the axis, you can reference a parameter. Then you can use the parameter control to move the reference line.
Basic Parameter Controls
The parameter control is a worksheet card that lets you modify the parameter value. Parameter controls are very similar to filter cards, in that they contain controls that modify the view. You can open parameter controls on worksheets and dashboards and they are included when you save to the web or publish to Tableau Server.
Parameter controls first appeared in Tableau several years ago, and they have become a popular feature. To make parameters easier for novice users, Tableau created basic parameter types that are built into typical use cases that benefit from variables. These include:
- Reference line parameters
- Bin size parameters (for histograms)
- Ranking parameters (in value comparison views)
The steps required to add basic parameter controls to a view are provided straightforward, so that you know that they exist. Figure 6.9 is a scatter plot that includes basic parameter controls for the vertical and horizontal reference lines.
There are two reference line parameter controls in Figure 6.9 that enable a user to change the location of the reference lines. These variable controls are built into the same dialog box where standard fixed reference lines are created. To create the parameter, right-click on the axis and select Add Reference Line to expose the reference line dialog box, and then in the value box, select the create a new parameter option. Figure 6.10 shows the added reference dialog box on the left. Selecting the create a parameter option in the value menu exposes the edit parameter window on the right of figure 6.10.
Figure 6.9: Reference line parameters
The edit parameter window is where you name and define the parameter. A comment field can be used to hold notes describing the parameter. The properties section is used to define the parameter type. In this example, a floating decimal point value is selected, the display format is currency, and the parameter is defined for a range of values with a specified increment defined by the step size. Clicking the OK button adds the parameter control. Refer to figure 6.9 again and notice that the parameters allow users to move a slider to change the position of the reference lines.
A second basic parameter type is available for making variable bin sizes in histograms. The view seen in figure 6.11 was initially constructed by selecting the profit field and then picking the histogram chart type from the show me menu. This results in a bin size of five thousand dollars with a very large concentration of items in only two bins.
Figure 6.10: Creating a reference line parameter
Figure 6.11: A basic histogram
Right-clicking on the Profit Bin dimension that Show Me automatically created allows you to select a parameter option for bin size in a manner similar to the last example. By defining a smaller step size for each bin, more granular views of the profit bins can be seen. This is always desirable when viewing histograms. The view seen in Figure 6.12 shows the Profit Bin Parameter set to a smaller value.
The ability to vary bin sizes within histograms can be very useful. As you can see in Figure 6.12, labeling was also added to each bar providing an item count and the total profit or loss expressed in each bin.
Another type of basic parameter is built into charts for creating variable sized rank lists. Figure 6.13 shows a bar chart comparing sales values by customer with a year filter. Notice the Parameter Control provides a variable rank list size for the top customers.
Figure 6.12: Parameterize bins in a histogram
Figure 6.13: A top rank parameter
In this example, the parameter control was invoked by right-clicking on the customer name pill on the row shelf, selecting the top filter tab, and defining the parameter range value for the number of customers you want to display in the bar chart. Figure 6.14 shows the complete top 10 filter. This isn’t the only way you can create a flexible rank list, but it is one of the easiest methods.
Figure 6.14: Quick filter with sales parameter
By placing the sales parameter into a normally static top rank definition dialog box, it creates a flexible rank list. This isn’t the only way you can create a flexible rank list, but it is one of the easiest methods.
Advanced Parameter Controls
More advanced parameter controls can be created that provide greater flexibility. The steps required to create advanced parameters are:
- Create the parameter control.
- Expose the parameter control on the desktop.
- Create a calculated value using the parameter control.
- Use that calculated value in the view.
Advanced parameters do require a little more effort, but they are easy to build once you become familiar with the process. One of the most common use cases for advanced parameter controls is to permit users to alter the measure being plotted in a view. Figure 6.15 shows a time series chart that is currently displaying sales over time, but with a parameter control it allows the end user to change the measure in view to profit, discount, order quantity, or shipping cost.
The Parameter Control contains strings identifying each different measure. Selecting the Parameter Controls’ drop-down menu exposes each measure— allowing the user to change the time series chart. Also notice that view contains parameterized headings for both the report title and the axis label. Take a look at the step-by-step creation of the Parameter Control for this example.
Create the Parameter Control
You can create the parameter control from the calculation menu or directly from the Data Shelf by right-clicking within the Dimensions shelf and selecting the create parameter menu option. This exposes the parameter menu through which you can enter the options as shown in figure 6.16.
Figure 6.15: A parameterized time series chart
Figure 6.16: Defining a string parameter
Notice that the parameter is named select measure, which is what appears in the parameter quick filter title. It may seem counter intuitive that the parameter definition is for a string type versus a number a string is necessary to contain the field names of the measures, that will be enabled in the view. This step only defines the filter box that is exposed on the desktop.
Exposing the parameter control
To make the parameter control available to information consumers, it must be exposed to the worksheet. This is done by pointing at the parameter title that appears on the parameters shelf, right-clicking and selecting the menu option show parameter control. After this step, the control is available on the desktop to make selections.
Now, I’ve got a new parameter, so expose it.
Then, it appears here.
It looks like an input, but it does not work at this point.
Create a calculated value using the parameter control
Making a calculated value that uses the parameter control brings it to life. Figure 6.17 shows the completed calculated value.
Figure 6.17: Select measure calculated value
The calculation uses an if/then/else logical statement to evaluate each string contained in the parameter and then associates the selected string with a specific measurable field. With the completion of this calculated value only one step remains to activate the parameter within the view.
Use the calculated value in the view
Placing the select measure calculated value on the row shelf activates the parameter. Figure 6.18 shows the complete view.
Figure 6.18: A parameterized time series chart
Adding the select measure value to the view connects the parameter control to the view and changes what is communicated to the data source when a different measure is selected within the parameter control. The select measure filter now allows users to change the measure to any of the items added in the parameter and the calculated value. Notice that the report title contains the parameter name. Also, the axis label is variable as well. Enabling these refinements requires a couple of extra steps. First, edit the report title and insert the parameter name into the title block. Then, drag the parameter from the parameter shelf to the axis and add the name variable there as well. By editing the axis label and removing the row heading, you can achieve a clean look that flexibly names the report and the axis.
There are many other ways you can use Advanced Parameters but the basic process for all of them follows these four steps. As you gain familiarity with Tableau’s calculation functions, you will think of many different ways to leverage Advanced Parameter Controls.