Last Modified Date: 11 Jan 2023
Environment
Tableau DesktopAnswer
Filtering a target sheet by either clicking a source sheet or checking options in a card can be accomplished by showing the card for a filter action or a set tied to an action.
Option 1: Using a Set and Set Action
These directions use the sample data set Superstore to create a dashboard where a bar chart can be filtered either by clicking on a map or a checkboxes in a set card. The workbook can be downloaded from the right-hand pane of this article, and also includes an advanced formatting option.Step 1: Create the set
- Right-click [State/Province] in the data pane and select Create > Set...
- Click Ok to close the Create Set dialog
Step 2: Create the source sheet map
- Double-click [State/Province] in the left-hand data pane
- In the dropdown on the Marks card, select Map
- Drag [State/Province Set] to Color on the marks card
- Right-click [State/Province Set] on Color and check Show Set
- Check at least one but not all states in the set card (this step makes both "In" and "Out" available for formatting)
- Click Color on the Marks card and click the Edit Colors... button
- In the Edit Colors dialog, select the desire color for "In" and "Out" and click OK
Step 3: Create the target sheet bar chart
- Drag [State/Province] to the Rows shelf
- Drag [Sales] to the Columns shelf
- Drag a second copy of [Sales] from the data pane to Label on the Marks card
- Drag [State/Province Set] to the Filters shelf
Step 4: Create the dashboard and set action
- Create a new dashboard
- Drag the "Profit State Map (basic formatting)" worksheet created in step 2 and the "Sales per State" worksheet created in step 3 onto the dashboard
- Navigate to Dashboard > Actions...
- In the Action dialog, do the following and click OK:
- Click Add Action > Change Set Values...
- For Source Sheets, check "Profit State Map (basic formatting)"
- For Run action on, choose Select
- For Target Set, select State/Province Set
- For Running the action will, select Add values to set
- For Clearing selection will, select Remove all values from set
Option 2: Using a Filter Action
These directions use the sample data set Superstore to create a dashboard where a bar chart can be filtered either by clicking on a map or a checkboxes in a set card.
Step 1: Create the source sheet map
- Double-click [State/Province] in the left-hand data pane
- In the dropdown on the Marks card, select Map
- Drag [Profit] onto Color on the Marks card
- Click Color on the Marks card and click the Edit Colors... button
- In the Edit Colors dialog, do the following and click OK
- Check Stepped Color
- Type in 4
Step 2: Create the target sheet bar chart
- Drag [State/Province] to the Rows shelf
- Drag [Sales] to the Columns shelf
- Drag a second copy of [Sales] from the data pane to Label on the Marks card
Step 3: Create the dashboard and filter action
- Create a new dashboard
- Drag "Profit State Map" created in step 1 and "Sales per State (2)" created in step 2 onto the dashboard
- Navigate to Dashboard > Actions...
- In the Action dialog, do the following and click OK:
- Click Add Action > Filter...
- For Source Sheets, check "Profit State Map"
- For Run action on, choose Select
- For Target Sheets, check "Sales per State (2)"
- For Clearing selection will, select Show all values
- Under Filter, choose Selected fields
- Click Click to add and select [State/Province]
- Click the "Sales per State (2)" viz on the dashboard to select it, and then click on the down arrow icon on the gray border and select Filters > Action (State/Province)
Additional Information
Filter actions and set actions behave differently, and the best option will depend on the use case:
- Option 1
- may be a good choice for when both the source sheet and the set card are shown on the same dashboard
- interacting with either the source sheet or set card update the set used to filter the target sheet
- this option does require more work to set up
- Option 2
- may be best for when the original filter action also navigates the user to another dashboard/worksheet
- interacting with either the source sheet overwrites all filter selections
- this means that if a user checks "Alabama" in the filter card and shift-clicks another state on the map, then the "Alabama" selection will be lost.
Notes on option 1
- The directions in this article use the set to color states so that it's clear which states the user has selected, but this is not necessary for the filtering behavior
- Actions do not affect how the selected marks look. This means that if the user shift-clicks states one at a time, only the most recent state appears selected even though the target sheet is filtered to all clicked-on states.
- The advanced formatting option included in the downloadable workbook has two changes:
- Map is colored by profit bins and selected states appear brighter. This is achieved by adding both the set and a profit bins calculated field to Color
- No states appear selected when clicking the map, only the color and filter updates. This is achieved by having a highlight action run on a dummy field with the same value for all marks. This method does not work with map layers.
Notes on option 2
- If the Filter Action filters on more than one dimension, the final filter will list combinations of dimension values as comma separated lists. To create filters that show only one dimension value per selection, create multiple Filter Actions that each only have one Target Filter.
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials