Show Table of Contents
Parameters are useful when you want to add interactivity and flexibility to a report, or to experiment with what-if scenarios. Suppose you are unsure which fields to include in your view or which layout would work best for your viewers. You can incorporate parameters into your view to let viewers choose how they want to look at the data.
When you work with parameters, consider the following two things that are important in making them useful:
Before you begin, decide which fields you want to make interactive. For example, you could allow users to view the categories within a dimension by color, or to view sales data over a period of time that they choose, and so on. The example described here sets up a table for which users can select the dimensions to display in the columns and rows.
Tip: To learn how to create parameters for what-if and other common scenarios, see the on-demand training video Parameters on the Tableau website. Also see Use Parameters to Add Multiple Views to Your Viz and Using a parameter to change the view in a dashboard.
These steps use the Superstore sample to create a new parameter while you build the calculated field that will take advantage of it.
Select Analysis > Create Calculated Field.
In the Calculated Field dialog box, for Name, type Column 1 Category.
Next to Parameters, click Create, and in the Create Parameter dialog box, complete the following steps.
Note: This example uses the customer name, customer segment, region, department, and category fields. These are all dimensions of the same data type (string). If you wanted to include a measure such as profit in this list, one option would be to convert the measure to a string value. You would do this when you build the calculated field, using the
STR() function. This article covers only the single data type scenario.
The Display As aliases default to the field name, and for this exercise you can leave them as they are.
Repeat the previous step to create the following additional parameters:
Tip: Instead of typing each value in the list, click Add from Parameter to add them from Select Column 1 Heading.
In the Calculated Field dialog box, for Formula, build the following calculation:
CASE [Select Column 1 Heading]
WHEN 'Customer Name' THEN [Customer Name]
WHEN 'Customer Segment' THEN [Customer Segment]
WHEN 'Region' THEN [Region]
WHEN 'Department' THEN [Department]
WHEN 'Category' THEN [Category]
Confirm that the status message indicates that the formula is valid, and then click OK.
Note: ELSE accounts for the None value that you included in the parameter, and it returns an empty string.
Create three more calculated fields, one for each of the additional parameters you created:
|Parameter name||Calculated field name|
|Select Column 2 Heading||Column 2 Category|
|Select Row 1 Heading||Row 1 Category|
|Select Row 2 Heading||Row 2 Category|
The basic formula for each calculated field is the same as in the previous step, except that you reference a different parameter in each
Now you expose the parameter control so users can select the categories they want to display.
For each parameter you created, do the following:
In the Parameters pane, right-click the parameter and select Show Parameter Control.
From the Dimensions pane, drag the calculated fields you created to the Columns and Rows shelves.
From the Measures pane, drag a measure to the view. In this example, Sales is placed on Label on the Marks card.
Test your parameters by selecting fields in the parameter controls.
Reset all parameters to None and publish the workbook to Tableau Server.
Viewers can set up their own reports, save their parameter settings, and share views with others.
For information about building views dynamically, see Swap Measures Using Parameters.
For information about the different areas in the Tableau interface in which you can create and incorporate parameters, see Parameters and its related topics in the Tableau Help.
Disclaimer: This topic includes information about parameters from a third-party blog, The Information Lab: Data School. Please note that while we make every effort to keep references to third-party content accurate, the information we provide here might change without notice as content on The Information Lab: Data School changes. For the most up-to-date information, please consult The Information Lab: Data School blog.