Set Actions

Use set actions to let your audience interact directly with a viz or dashboard to control aspects of their analysis. When someone selects marks in the view, set actions can change the values in a set. For examples on how set actions can be used, see Examples of set actions.

Image showing dashboard that using set actions. A user selects a mark in one part of the dashboard to control the values that display in another part of the dashboard.

Set actions take an existing set and update the values contained in that set based on user actions in a viz. You can define the set action to include:

  • the source sheet or sheets it applies to.
  • the user behavior that runs the action (hover, select, or menu).
  • the target set (the data source and set to be used).
  • what happens when the selection is cleared.

To change or affect a visualization, the set referenced in the action must be used somehow in the visualization. You can do this in different ways, such as using the set in a calculated field that you then use to build the viz, or by placing the set in the view or on a Marks card property.

You can create set actions in Tableau Desktop, Tableau Cloud, and Tableau Server. However, set actions can't be used with Stories.

General steps for set actions

  1. Create one or more sets. The sets you create will be associated with the data source that is currently selected. For details on creating sets, see Create Sets.

  2. Create a set action that uses one of the sets you created. You can create multiple set actions for different purposes.

  3. Depending on the behavior you want to make available to users for their analysis, you might want to create a calculated field that uses the set. For details on creating calculated fields, see Create a calculated field.

  4. Build a visualization that uses a set referenced by a set action. For example, if you create a calculated field that uses the set, build the view using that calculated field. Or, drag the set to Color in the Marks card.

  5. Test the set action and adjust its settings as needed to get the behavior you want your audience to experience.

Getting Started: For an overview of what you need to know to create set actions, see On Your Marks, Get Set, Go: Everything You Need to Know to Get Started with Set Actions(Link opens in a new window) on the Data Viz Linds(Link opens in a new window) blog.

Create a set action

  1. In a worksheet, select Worksheet >Actions. In a dashboard, select Dashboard >Actions.

  2. In the Actions dialog box, click Add Action and then select Change Set Values.

    Actions dialog box with Add Action button clicked and Change Set Values action selected to create a set action.

  3. In the Add/Edit Set Action dialog box, specify a meaningful name for the action.

  4. Select a source sheet or data source. The current sheet is selected by default. If you select a data source or dashboard you can select individual sheets within it.

    Add or Edit Set Action dialog box showing different settings for set actions.

  5. Select how users will run the action.

    • Hover - Runs when a user hovers the mouse cursor over a mark in the view.

    • Select - Runs when a user clicks a mark in the view. This option works well for set actions.

    • Menu - Runs when a user right-clicks (control-clicks on Mac) a selected mark in the view, then selects an option on the context menu.

  6. Specify the target set. First, select the data source, and then select the set.

    The sets available in the Target Set lists are determined by the data source that you select and the sets that you have created in the workbook that are associated with that data source.

    Add or Edit Set Action dialog box showing different settings for set actions.

    In this example, the target set is using Global Superstore 2016 as the data source and High Shipping Cost Orders as the set.

  7. Specify what happens when the action is run in the view:

    • Assign values to set - Replaces all values in the set with the values selected.

    • Add values to set - Adds individually selected values to the set.

    • Remove values from set - Removes individually selected values from the set.

  8. Note: Selecting Add values to set or Remove values from set via the Set Action dialog modifies the values selected in the General tab of the set’s definition—just like Assign values to set does. This differs from the Add to and Remove from functionality available only in authoring mode via the set’s context menu in the tooltip. The latter unions or removes values to and from the set after the condition specified has been applied.

  9. Specify what happens when the selection is cleared in the view:

    • Keep set values - Current values in the set remain in the set.

    • Add all values to set - Adds all possible values to the set.

    • Remove all values from set - Removes previously selected values from the set.

  10. Click OK to save your changes and return to the view.

  11. Test the set action by interacting with the visualization. Tweak some of the settings for the action to adjust the selection behavior as needed.

Examples of set actions

The following examples show just a few of the ways you can use set actions. To follow along, you will need to be familiar with creating and using sets and calculated fields. For details, see Create Sets and Create a calculated field.

Proportional brushing

A classic use case for set actions is proportional brushing, described in How to do proportional highlighting with set actions(Link opens in a new window) on the Tableau blog(Link opens in a new window) and Tableau Set Actions(Link opens in a new window) from The Information Lab blog(Link opens in a new window) (along with other examples).

Set action example showing proportional brushing in a dashboard. Clicking a bar in view shows the proportion of values in the other bar chart.

Proportional brushing example details

This example uses the Sample - Superstore data source. This set action changes the color of existing marks in the view based on the proportion of the mark that is in or out of the set.

  1. Connect to Sample - Superstore data in Tableau Desktop.

  2. In a new sheet, drag the Sales measure to Columns, and drag the Segment dimension to Rows.

    Fields that are used to create a Sales by Segment visualization.

  3. In another blank sheet, drag the Sales measure to Columns, and drag the Sub-Category dimension to Rows.

    Fields that are used to create a Sales by Subcategory visualization.

  4. Create a set for the Segment dimension named Segment Set.

    Right-click Segment field, select Create, and then select Set.

  5. In the sheet that shows Sales by Sub-Category, drag Segment Set onto Color in the Marks card.

    Segment set placed on the Color property in the Marks card.

    Swap the colors used to show marks IN or OUT of the set.

  6. Create a new dashboard. Drag both sheets into the dashboard.

    On the Dashboard menu, select Actions. Click Add Action, and then select Change Set Values.

    Open the Actions dialog box from the Dashboards menu.

  7. Configure the action using the same settings as shown in the image below.

    Name set action Proportional Brushing, select the dashboard and both sheets, Run action on Select, set Target Set to Superstore database and Segment set, set clear selection to Add all values to set.

  8. Click OK to save your changes and return to the view.

  9. Test the set action by clicking the marks for each segment.

 

Asymmetric drill down

Set actions can also be used across multiple sets for more complex interactions. If a data set has hierarchical information, such as Category, Sub-Category, and Manufacturer, normally drilling down the hierarchy expands all values at a given level. However, you can use set actions for asymmetric drill down, opening only the next hierarchy level for the selected value.

Set action example.

Asymmetric drill down example details

This example uses the Sample - Superstore data source.

Set actions are used here in conjunction with two calculated fields to create an asymmetric drill down experience.

  1. Create a set for the Category field named Category set.

    Choose any category to be a member of that set. The membership is temporary and will be overwritten by the set action.

  2. Create a calculated field named Asymmetric Sub-Category.

    Right-click the Sub-Category field in the Data pane, and then select Create Calculated Field.

    Type the following calculation:

    IF [Category set] THEN [Sub-Category] ELSE [Category] END

    Calculation window showing calculation.

    If the category of the mark or marks in the view is in the Category Set, the calculation will return the Sub-categories for that Category. Otherwise, it will return the Category again.

    The set isn't in use in the view yet and has no action associated with it, so it is static for the moment.

  3. Build the view by dragging the Category and Asymmetric Sub-Category fields to Rows (in that order). Then Drag Sales to Text in the Marks card.

    Set action example.

  4. Create a set action.

    On the Worksheet menu, select Actions. Click Add Action, and then select Change Set Values.

    Name the action Asymmetric Drill to Sub-Category.

    Add Set Action dialog box with settings.

    Select the following options:

    • Source Sheets: Make sure the only the current sheet is selected.
    • Run action on: Choose Select. This will make the action apply when the user selects a mark or marks in the view.
    • Target Set: Select the current data source from the first drop-down list and the Category set from the second drop-down list.
    • Clearing the selection: Select Remove all values from set.

    Click OK to save your changes.

  5. Test the set action.

    When you click on a header or mark in the view, it will expand out to the next level. Clicking a category bar will expand its sub-categories.

Color scaling

Color values in a viz often can be distorted by outliers. When one country has a significantly higher value than other countries, the nuance of differences between those non-extreme values can be lost.

A set action can update the values in a Country set based on the selection in the viz. That set is then used in a calculated field that computes the value of the relevant measure for only countries in that set, and that calculated field is placed on color. Now, when countries are selected in the map, the color palette is based only on those countries, showing greater visual differences between those values.

Example showing selection of subset of marks in world map. Color value range changes depending on the selection.

Color scaling example details

This example uses the Global Superstore data source.

  1. Create a set on the Country field named Country set. Chose any country to be a member of the set. The membership is temporary and will be overwritten by the set action.

  2. Create a calculated field named Country Shipping Cost.

    Right-click in the Data pane, and then select Create Calculated Field.

    Type the following calculation:

    IF [Country set] THEN ([Shipping Cost]) END

    Calculations window showing calculation.

    If the country of the mark(s) in the view is in the Country set, the calculation returns the Shipping Cost. Otherwise, it does nothing.

    The calculated field ties the set into the view.

  3. Double-click the Country dimension to automatically create a map.

  4. Drag Country Shipping Cost to Color in the Marks card. The map should automatically update to a filled map.

    World map with Country Shipping Cost on color.

  5. Create the set action: Country color scaling.

    On the Worksheet menu, select Actions. Click Add Action, and then select Change Set Values.

    Name the action Country color scaling.

    Edit Set Action dialog box.

    Select the following options:

    • Source Sheets: Select only the current sheet.
    • Run action on: Choose Select. This will make the action apply when the user selects a mark or marks in the view.
    • Target Set: Select the current data source from the first drop-down list and the Category set from the second drop-down list.
    • Clearing the selection: Select Add all values to set.
  6. Click OK to save your changes.

  7. Test the set action.

    When you select a mark or group of marks in the view, the color palette responds by representing the values for those marks, not the entire data set.

 

Relative dates

This dashboard example contains multiple relative date calculations. Based on a target date, the dashboard displays the difference from the previous day, the percent change from the same month in the previous year, the Year to Date sales for the current year, and Year to Date sales for the previous year.

The set action in this dashboard updates the target date and relevant date calculations in response to a user clicking a mark on a timeline.

Example that shows how clicking a timeline date updates other parts of the dashboard.

Relative date example details

This example uses the Global Superstore data source.

The set action in this example is applied to the Timeline sheet in the dashboard, and uses that sheet to drive the behavior of the dashboard. When a user selects a mark in the Timeline view, the set action updates the Selected Date set with a single date value.

In this example:

  • A Selected Date set is built on the Order Date field.

  • An Update Target Date set action updates the Selected Date set so the date value for the mark selected in the view is the only value in the set.

  • A Target Date calculated field captures the date value from the Selected Date set, and that calculated field is referenced by other relative date calculations in the viz.

  • Each sheet in the dashboard uses calculated fields to update its displayed values.

Note: Because this example is more complex, the description below gives a summary of the major steps and settings involved rather than specific details.

Timeline sheet settings

Sales is on Rows. A calculated field named Target Date is placed on Detail to make it available to the reference line.

Sales field placed on Rows shelf. Target Date calculated field place on Detail.

Starting in Tableau 2020.2: The above image doesn't reflect the latest user interface. For each table or folder in the Data pane, a gray line separates dimensions (above line) and measures (below line). The Dimensions and Measures labels are no longer used in the Data pane.

Order Date is on Columns as Exact Date.

Order Date placed on Columns self. Right-click Order Date field in the view to set the date type to Exact Date.

The reference line is applied to the Order Date field and is set to be the Minimum of Target Date.

Reference line applied to Order Date field. Reference line is set to be the minimum of Target Date.

A set action is applied to this sheet that updates the Selected Date set based on what mark is selected in the view.

Set action that acts on Selected Date set based on the selected mark.

Thanks for your feedback!Your feedback has been successfully submitted. Thank you!