KNOWLEDGE BASE

Filtering the Secondary Data Source Independent of the Primary


Published: 26 Feb 2013
Last Modified Date: 27 Oct 2017

Question

How to filter the secondary data source, at the row level, without filtering the primary data source.

Environment

  • Tableau Desktop 9.3 and earlier versions
  • Blended data

Answer

Use a parameter with a calculated field to filter the secondary data source at the row level.

The attached workbook and the following steps illustrate the process. In this example, Superstore Sales is the primary data source and Coffee Chain is the secondary data source.

Step 1: Create the Parameter

  1. Right-click in the Data window and then select Create Parameter.
  2. In the Create Parameter dialog box, name the parameter. In the example workbook, the parameter is named Select a Region.
  3. Under Data Type, select String.
  4. Under Allowable values, select List.
  5. Enter the desired values in the List of values
  6. When finished, click OK.
  7. Right-click the parameter and then select Show Parameter Control.
Note: the parameter belongs to the workbook and can be created from any data source (primary or secondary).

Step 2: Create the Calculated Field

  1. To create a new calculated field, from the primary data source (here: Sample Superstore), select Analysis > Create Calculated Field.
  2. In the Create Calculated Field dialog box, name the field. In this example, the calculated field is named Region Filter.
  3. In the formula field, enter the following formula: IF [Select a Region] = [Region] THEN [Region] ENDand then click OK.

Step 3: Create the View

  1. Double-click State to create the map view.
  2. Drag the Region field to the Color shelf on the Marks card.
  3. Click the drop-down arrow on the Marks card and select Filled Map.
  4. In the Data window, click the Coffee Chain data set.
  5. Drag Number of Records to Label on the Marks card.
  6. In the Data window, click the Superstore Sales data set.
  7. Drag the Region Filter calculated field to the Filters shelf.
  8. In the Filter dialog box, select the check box next to Null and the check box next to Exclude, and then click OK.

Additional Information

  • It is not possible to filter a secondary database at the row level using the Filters shelf, but it is possible to use a parameter in conjunction with a calculated field to filter the secondary data source at the row level. Whereas a filter simply excludes rows of data, logic can be applied to a calculated field to zero out certain rows if the given condition is met.
  • The calculated field must be built in the secondary data source, and must check to see if the current row matches the parameter selection, and return a value if it does, null or zero otherwise.
  • Quick filters cannot filter across data sources.
  • The parameter should contain all possible filter values.
  • The above steps apply to versions of Tableau Desktop 9.3 and earlier. For Tableau Desktop 10 and later versions, see Cross-data filtering in the Online Help documentation.
Did this article resolve the issue?