KNOWLEDGE BASE

Filtering Across Multiple Data Sources Using a Parameter


Published: 24 May 2013
Last Modified Date: 13 Feb 2017

Question

How to filter across multiple data sources using a parameter.

Environment

Tableau Desktop

Answer

Note: In Tableau Desktop 10.0 and newer versions, you can use filters across multiple data sources. For more information, see Filter Data Across Multiple Data Sources.

The below example uses the Superstore and Coffee Chain data sources, and can be seen in the attached packaged workbook.

Step 1: Create the initial view

  1. Open Tableau Desktop and connect to the Superstore sample data source.
  2. (If applicable) On the Data Source page, drag the Orders table to the canvas.
  3. Select Data > New Data Source, and then connect to the Coffee Chain data source.
  4. On the Data Source page, drag the CoffeeChain Query table to the canvas, and then click the sheet tab.
  5. Drag Date to the Columns shelf.
    1. On the Columns shelf, click the plus icon next to Year (Date) to also show Quarter, and Month. Remove Quarter.
  6. Drag Profit and Sales to the Rows shelf.
  7. Right-click Sales, and select Dual Axis.
  8. Right-click the new axis, and select Synchronize axis.
  9. Select Worksheet > New Worksheet and then select the Superstore data source in the Data pane.
  10. Drag Order Date to the Columns shelf.
    1. On the Columns shelf, click the plus icon next to Year (Order Date) to also show Quarter, and Month. Remove Quarter.
  11. Drag Sales to the Rows shelf.
  12. Drag Category to Color, and select Bar from the Marks drop-down list.
  13. Create a new dashboard, and then drag Sheet 1 and Sheet 2 to the canvas.

Step 2: Create a custom parameter and use it in a calculated field

  1. With your workbook open and displaying Sheet 1 (and the Coffee Chain data source), in the Data window, click the drop-down arrow at the top of the Dimensions pane, and then select Create Parameter.
    1. For Name, type Select State.
    2. For Data Type, select String.
    3. For Allowable Values, select List.
    4. Under List of Values, select Add from Field > Sample - Coffee Chain > State.
    5. When finished, click OK.
  2. Create a calculated field by selecting Analysis > Create Calculated Field.
  3. In the calculated dialog box, complete the following steps:
    • In the name box, enter State Filter.
    • In the formula box, enter the following, and click OK when finished.
      [Select State]=[State]
    • Note: This calculation checks whether the state selected in the parameter matches the state field in your data source, and then returns true or false.
  4. Drag State Filter to the Filters card.
  5. In the Filter dialog box, select True, and then click OK.
  6. Go to Sheet 2 (that uses the Superstore data source), and repeat steps 3 to 5.
    • Note: You do not need to recreate the Select State parameter.

Step 3: Use the parameter

  1. Go to the dashboard, click the drop-down arrow for one of the views, and then select Parameters > Select State.
  2. Select a state from the parameter control.
    • Note: Views that use either or both data sources refresh to show data from the selected state.

Additional Information

To view these steps in action, see the video below: 
Did this article resolve the issue?