A set action example

You'll find an example of a set action in the Chapter 7 Complete.twbx workbook in the dashboard named Sales by Region and Category (set actions), which looks like this:

The dashboard consists of two views: a map and a bar chart. Selecting a Region on the map triggers a set action that updates the bar chart. A filter action would filter the bar chart, causing the length of each bar to only show the value for the selected region. Here, however, the set action is used to show the portion of the overall bar that belongs to that region while still retaining the full length of the bar for all regions.

To replicate this interactivity, follow these steps:

  1. Use the drop-down menu on the Region field under Dimensions on the data pane to select Create | Set. Name the set Region Set.
  2. In the resulting Create Set dialog, under the General tab, check one or more values. This creates a fixed set. In this example, it does not matter which, if any, values you select because you'll configure the set action to update the values momentarily.
  3. Create a bar chart of Sales by Category.
  4. Drag the Region Set from Sets on the data pane and drop it on Color:

You may use a set on shelves, just as you would any other field. Notice how the set gives two values, that is, In and Out, which define two colors. You may wish to adjust the colors to emphasize In.

You may use sets in calculated fields as well. For example, the code [Region Set] gives a Boolean true/false result for each record, indicating whether it is In the set.

Conclude the set action example by creating a region map, the dashboard, and implementing the set action.

  1. Use the drop-down menu on Region to select Geographic Role | Create from... | State. This tells Tableau to treat Region as a geographic field based on its relationship with the geographic field State.
  2. In a new, blank view, double-click the Region field to create the map view. Now that Region is recognized as a geographic field, Tableau will generate latitude, longitude, and the geometries that are necessary to render the shapes.
  3. Add both the map and bar chart views to a single dashboard. You may position them however you'd like.
  4. Add a set action by selecting Dashboard | Actions from the menu and then Add Action | Change Set Values... in the resulting dialog. The resulting dialog has many similar features to other action types:

You'll notice options to give the action a Name; Run action on: Hover, Select, or Menu; and options for Clearing the selection. Just like other action types, you may also specify Source Sheets that trigger the action. The Target Set allows you to specify which data source and which fixed set in that data source will have values updated based on the action. In this case, we want to update the Region Set when a selection is made on the Sales by Region (set actions) view. We'll elect to Remove all values from the set when the selection is cleared.

Once you have created the preceding action, your dashboard should function very similarly to the example that was shown at the beginning of this section. Selecting a region on the map highlights the portion of the bars that correspond to that region. This technique is known as brushing, or proportional brushing.

This technique is only one of hundreds of the possible applications of set actions. Since sets can be used on any shelf and in calculations, updating the values via set actions opens up almost limitless possibilities for user interaction and analytics.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset