KNOWLEDGE BASE

Filtering Multiple Dimensions Using Parameters


Product(s): Tableau Desktop
Version(s): All
Last Modified Date: 16 Aug 2016

Article Note: This article is no longer actively maintained by Tableau. We continue to make it available because the information is still valuable, but some steps may vary due to product changes.


Quick filters allow you to easily remove data from the view and focus on just the information you need. When you are building a more complicated view or dashboard, you may find that you have added lots of quick filters to help people narrow down a large view to a specific set of data such as a single region or product. In that case, the quick filter controls can sometimes take up a lot of space and take attention away from the data in the view. To avoid that, you can create a Type In parameter that accepts values for multiple fields and then filters based on what you typed in.

The following example shows how to create a single text box on a dashboard that filters a list of customers by Region or Department. To create this type of filter, you will need to create a parameter, a calculated field, and a filter.

Note: Use this strategy when you want to filter on a single value at a time. For example, looking at only the West or only Technology products.

Create the parameter

The first thing you will need to create is a parameter. The parameter is where users will type in the Region or Product Category values.

Step 1 

Connect to your data source. This example uses the Sample - Superstore data source.

Step 2 

Right-click an empty area in the Data window and select Create Parameter.

Step 3 

In the Create Parameter dialog box, give the parameter a name such as Filter On. Then specify the parameter settings.

In this case, the parameter will accept Strings (i.e., text) and have the initial value of None. People will be able to type in any text they want because the Allowable values setting is set to All. When finished, click OK.

The new parameter displays at the bottom of the Data window in the Parameters pane.

Create a calculated field

Now that you have a parameter to collect the value you want to filter on, you need some way of specifying the filter. You can do that by writing a calculated field that compares the Region and Department values to the Filter On value.

Step 1 

Select Analysis > Create Calculated Field.

Step 2 

In the Calculated Field dialog box, do the following tasks:

  1. In the Name text box, type Show in View.
  2. In Formula text box, type the formula below, and then click OK.

IF [Region] = [Filter On] AND [Department] != [Filter On] THEN "Show"

ELSEIF [Department] = [Filter On] AND [Region] != [Filter On] THEN "Show"

ELSE "Hide" END

The above formula compares the Region and Department values for each row to the Filter On value that was typed in. If it matches one of the fields but not the other then it is marked as "Show" otherwise it is marked as "Hide."

Filter the view

The final step is filtering the view to only include the rows that were marked as "Show."

Step 1 

Drag the Show in View field that you just created to the Filters shelf.

Step 2 

Select the Show check box.

You may only see a check box for "Hide" depending on what you made your initial value for your parameter. For example, if you made it "None" like in this example, there are no records where Region or Department match the word, "None." If you do not see a check box for "Hide", select the "Custom Value List" radio button. Then type in the word "Show" and click the plus button to add it to the list.

Step 3 

When finished, click OK.

Build the view

Now that you have all the pieces, build the view you want. Make sure you show the parameter control by right-clicking the parameter in the Data window and selecting Show Parameter Control.

The example below shows the total sales for a list of customers. You can type in a specific region or department to filter the customer list. The view below is a live view. Go ahead and give it a shot. Type in a new region or department and press ENTER on your keyboard.

 

Did this article resolve the issue?