Hi! I’m , bringing the Red Headed Step Data blog back to life with this deep-dive post on Tableau Set Actions. In this article I catalog various design patterns for Set Actions and summarize each use case with supporting resources. This post is a long one, and it may be too much to absorb in one reading. So please feel free to return to it as reference during the design phase of your future projects.
As of this writing, my colleague has just delivered a to demonstrate the power of Set Actions. He did a great job and I highly recommend to watch the recording. This article is a companion to that webinar, and it provides a great many links to the references and resources that unpack the detail behind each of these use cases.
Interactive is the Future
Set Actions were released with Tableau version 2018.3 and they unleash a world of new possibilities. They bring to life a dramatically increased ability for Tableau authors to tightly couple customized computation with our end users' activity.
In prior versions of Tableau, the various hacks and workarounds that were required would dramatically increase the complexity of our craft. And that complexity placed the kind of advanced analysis that is now available out of reach from most creators. So now, by lowering the barrier of entry to this kind of rich dashboard interactivity, Tableau has raised the bar for the experts to continue building upon their proficiency.
The Basics of Sets in Tableau
A SET in Tableau defines a specific criteria to partition the members of a dimension into 'in' or 'out' groups. Sets in Tableau are created on a single dimension, and they can be used across the entire data source. If the condition is true for a given record, then that record is included in the Set (“IN”). And if the criteria are not met, then the record is excluded from the Set (“OUT”). Both dimensions and measures can be used in the criteria, and Sets are treated as a BOOLEAN data type. They can be used within other calculations, and multiple Sets can be combined together to isolate the overlapping members.
An Introduction to Set Actions
Set Actions update the members of an existing Set based on a user’s interaction in the viz.
The Set Action is defined to include:
- the source sheet or sheets that the action applies to
- the target Set, whose members are updated
- the user’s behavior that will initiate the action
- and what happens when the selection is cleared
For comparison, with a Filter Action: only the values that qualify remain in the view. Everything else is filtered away. But with a Set Action: all of the data remains in the worksheet. And all of the data is still available for us as authors to utilize. Only the membership of the Set has changed.
There are so many ways that Set Actions can be used. Let’s deep-dive the use cases one by one.
- Use the Set in a Viz
- Color by a Selection
- Set Shape or Size by a Selection
- Sort by a Selection
- Group by a Selection
- Compute Selection as a % of Total
- Use the Set in a Set
- Filter on a Related Field
- Group By a Related Field
- Use the Set in a Calculation
- Filter a Measure by a Selection
USE CASES
Use the Set in a Viz
Color by a Selection
Now with Set Actions we can use a separate highlight color when a user interacts with the viz. Previously, with highlight actions, we could only highlight the color that was already applied to the viz, leaving the unselected marks opaque. Set actions now enable a more distinctive and apparent visual difference between the selected and unselected marks.
The example above was originally published in . A recent #WorkoutWednesday challenge also used Set Actions to achieve cross-highlighting (row and column) on hover. See for the steps to build that one.
Set Shape or Size by a Selection
Combining a color change together with a shape change will dual encode the user’s selection. In the example, selecting a year in one worksheet changes both the color and the shape of the marks. This is done with a single Set on Year of the Order Date.
In , a user can choose to either include or not include a region of data. Once selected, it changes the color and shape of the icon to indicate whether that region is now a part of the calculations.
Sort by a Selection
When sorting by the user’s selection, we not only sort the marks in the view but we also enable a more concise analytical examination, with a lower cognitive burden. In the sort order of a stacked bar chart is changed dynamically to put the dimension members we select on a common baseline. Without the ability to move “Lead” down as the first item in the axis, we’re unable to make a direct visual comparison by the date period. And notice: even though we’ve chosen to click & sort by a value, the other values are still available in the view (they were not filtered away).
For more on why utilizing a common baseline benefits chart comprehension, read by Steve Wexler.
Group by a Selection (Proportional Brushing)
Proportional brushing allows you to select marks in one view and, instead of filtering, show the proportion of those selected items in relation to the whole. In the post , selecting countries on the left worksheet adds the selected members to a Set (blue color). And this allows for easy visual comparison between the total value of the unselected countries (grey color). Because Set Actions don’t remove data from a view like a Filter Action does, the unselected grey countries can be used in calculations.
Compute a Selection as Percent (%) of Total
Because Set Actions allow us to perform calculations on the unselected marks (the members that are not in the Set), the ability to compute the selection as a percent of total is interactive now. In , all countries are visible on the map. Selecting, and thus filtering, on a country would remove the ability to calculate the percent of total. But with Set Actions, we can keep all the data in the view and perform a percent of total calculation to show the part to whole relationship.
Use the Set in a Set
Filter on a Related Field
This is super powerful, because now the relationships in the data drive the view. In we can see a selected team while also seeing all other teams that are related to that team. There are two Sets used to accomplish the interactivity: the first stores the selected value, while the membership of the second Set is conditional on whether a team has played against the selected team (related). The second Set is used as a filter, to remove the unrelated teams from the view. This enables the user to select a given team, and filter the view to only those other teams which have played against the selected team. for more examples of this powerful relational analysis in a business world scenario.
Group by a Related Field
Here again we can use one set inside of another to highlight relationships in the data. The product subcategories in are listed by quantity of orders. When the user selects a subcategory, the other subcategories are then divided up between those that were purchased together with the selected subcategory at checkout. This shows which product subcategories are complementary to each other at the time of sale.
Similar to the earlier example, filtering on a related field, this technique allows us to see the relationship between the “IN” members (subcategories purchased together) and the “OUT” members (subcategories not purchased together with the selected subcategory).
Use the Set in a Calculation
Filter a Measure by a Selection
Filter a Single Axis for Part to Whole
In the slope chart example , interactivity enables a part to whole analysis. The user selects a team in one worksheet (map), updating the members of a Set which sorts and filters the measure values in a destination worksheet. The analysis compares all teams’ rankings against a selected team’s ranking for each position. The difference in rank between the two is encoded not only as a shift in sort order and length of bar, but also as the mark color. Where dashboard filters would remove data from the entire worksheet, with Set Actions we can isolate that filter to only a single axis.
Filter a Single Axis for Part to Part
demonstrates Set Actions interactivity enabling “Part to Part” analysis. Each team is represented as a row down the left side of the viz and a matching list of teams is represented across the bottom. The unselected state of the viz shows an average value per position trended diagonally, increasing in value on both axes thanks to the sort. When a team is selected on the Y axis, that team’s position value is then compared to the average player value of all teams. And when a second team is selected on the X axis, those two teams are compared directly to one another. Each mark represents the value of a particular position, but according to the selected teams’ independent values. The marks above the diagonal line represent those positions that one team values more highly than the other team does in comparison.
Filter a Term in a Calculation
Difference from Summary Average
As an alternative, instead of isolating the items selected into the Set on an axis, we can also isolate the items selected into the Set inside of a calculation. demonstrates another part to whole analysis. Here each team is sorted descending by value, and a reference line represents the average value of all the teams. The user can select multiple teams (adding them into a Set). And in the lateral worksheet each individual team is then compared to an average that is calculated across selected Set. This shows, for each team in the data, their difference from the selected average.
Difference in change between Selection and Total
In , stocks are compared to each other based on their daily performance, relative to all other stocks in the data. This comparison enables the user to select a single stock and see easily whether that chosen stock is gaining on more days relative to all other stocks in the data. This viz answers whether the chosen stock is increasing “because there is something special about that stock”, or increasing only because all other stocks are also increasing.
The interactivity of the viz is enabled by a single Set on stock name. However it also requires several level of detail calculations. The line graph plots the daily average close price per stock and the quick filter controls which stocks are visible in the view. The pie graph represents whether a stock has gained on more days than it has lost or stayed equal. The histogram charts a count of days on the x axis, while the y axis (height of bar) is a count of stocks. Each worksheet is using the Set in its own distinctive way. The line graph stores the value of the chosen stock’s name. The pie uses that chosen stock to compute the portion of the days it lost to the days it gained (versus the remainder of the market). And the histogram takes it a step further by computing the days that the chosen stock gained or lost compared to the entire market.
Difference in Rank
demonstrates four types of rankings based on different sales metrics: overall, corporate, technology and city-by-state.
When a user selects a city in the Sales by City list, that city is added into a Set. The three adjacent worksheets then use that Set to determine which two cities are ranked above and below, based on that sheet’s particular criteria. This is achieved by using a combination of Set Actions (interaction and selection storage), Table Calculations (lookup to find previous and next city values, rank), Level of Detail expressions (number of cities being compared for each ranking) and sort. Bethany Lyons contributes an alternative method for by adding a parameter that lets the user control how many similar cities are returned.
Percent Difference from a Selection
In average housing prices are compared by selected outcodes (regions). These outcode are colored on the map based on their difference from the average house price of the selected outcodes Set. There are two complementary worksheets (main and legend) that each have different levels of detail visible in the view. The main worksheet has all of the outcodes as discrete regions, where the legend shows only two distinctions: selected outcodes and unselected outcodes.
Since the lowest level of detail in the main viz is the outcode region, we want to take the average of all home prices in the selected outcodes (not the average of the average home price in each outcode). Taking the average of the average in this case is analytically wrong, because we want the average of the underlying data. So level of detail calculations, used in tandem with Set Actions, allows for this interactivity. And it returns the values that are analytically correct.
Part to Part Analysis
Difference between Subsets
The dashboard compares housing pricing during different date ranges. In addition, we see how those prices trend across the entire date range available. There are two Sets that enable this interactivity, a Set for “Period 1” years and a Set for “Period 2” years.
When the user selects these date ranges, the bar chart is updated to show, on average, how the district prices have changed in comparison from “Period 1” to “Period 2”. The show the difference in big bold numbers in both percent and average price. The line graph is special because it charts not only the 12 month running average of home prices, but it also isolates the date ranges for “Period 1” and “Period 2”. This is does by calculating reference bands on both the x and y axes, which calls attention to the selection.
Apply a Computed Sort on a Selection
In , there are three sort options available via parameter: overall, selection and percent of total. The map allows the user to select individual countries (adding them into a Set). The bar chart then lists the position value for the selected countries compared to the whole. And depending upon the sort option, the list is sorted based on the computed measure.
allows the user to select bins (adding days and stocks into a Set) that represent the percent that a stock changes by day. When a bin is selected, that value is prioritized as the sort axis, and stocks that do not have days meeting the selected criteria are removed. Instead of using just the stock or the day in a Set, it is using a calculation on both to provide interactive analysis on the distribution of daily change.
Display Selected Value as Reference Lines
Drop Lines
Although Tableau Desktop has a built-in feature to display drop lines when clicking on a mark, that functionality doesn’t work on Tableau Public or Tableau Server. In , Lindsey Poulter surpasses this limitation with Set Actions and three layers of transparent worksheets. One of the layers of the viz dynamically calculates reference lines based on the selected mark. This creates a line that spans across the entire axis. However, to complete the illusion of drop lines, the line beyond the mark’s value is overlaid by a different worksheet which uses reference bands to mask the values that exceed the selected mark’s value.
Dynamic Reference Bands
Matt Chambers demonstrates in how to use a Set Action selection to draw dynamic reference bands from the minimum to the maximum values of the selected Set member. Using a combination of Sets and Table Calculations, a category can be selected (adding it into a Set). And the table calcs highlight the Window Minimum and Window Maximum values as a reference band.
This effect is also used in . Here the technique is used to select marks along the date axis and focus the calculations on those selections. The selected date range is highlighted as a reference band that persists, while allowing the user to continue to interact with the other sheets in the viz. Notice how this interaction allows you to NOT SELECT some marks within the date range, which excludes them from the subsequent calculations.
In the example you can see the same date range is highlighted, but with fewer marks. Compare the selected sales bar chart and you’ll see a difference between those marks that remain unselected, even while the date range spans across the same amount of months.
Conclusion
While very comprehensive, the examples I’ve provided here truly only scratch the surface of what is possible now with Set Actions. My aim for the post is to catalog many of the possible use cases, and link out to their references as a one-stop shop.
Please return to reference these use cases as needed. And . Interactivity in dashboard design is the future. If you need consulting help with Set Actions or Tableau, reach out to us as . And I hope these examples will bring new enthusiasm to your creation of dynamic, interactive analytics experiences with Tableau!
Word Count: 3066
References
- Ryan Gensel - Action Analytics Team
- Keith Helfrich - Action Analytics Team
- Webinar for Tableau Software - Rich interactive analytics with Tableau Set Actions, May 23, 2019
- How To: Highlight With Color Using Set Actions with Tableau, Matt Chambers, November 1, 2018
- How to create a cross highlight action in Tableau, Sean Miller, November 7, 2018
- Tableau Set Actions, Marc Reid, October 30, 2018
- Use Icons to Add and Remove Values from a Set, Lindsey Poulter, November 14, 2018
- Improved Stacked Bar Charts with Tableau Set Actions, Dorian Banutoiu, February 27, 2019
- How to take the “screaming cats” out of stacked bar and area charts, Steve Wexler, November 25, 2017
- How to do proportional highlighting with set actions in the latest Tableau beta, Andy Cotgreave, August 2, 2018
- Example 1 - Percent of Total, Bethany Lyons, November 1, 2018
- Filtering on a Related Field, Bethany Lyons, December 3, 2018
- Webinar for Tableau Software - Rich interactive analytics with Tableau Set Actions, May 23, 2019
- Market Basket Analysis - Set Actions, Bethany Lyons, December 12, 2018
- Example 3 - Difference in Rank, Bethany Lyons, November 1, 2018
- Example 4 - Part to Part, Bethany Lyons, November 1, 2018
- Example 6 - Difference from Summary Average, Bethany Lyons, November 1, 2018
- Example 8 - Change of Selection Relative to Overall Change, Bethany Lyons, November 1, 2018
- View Similarly Ranked Items Using Set Actions and Table Calcs, Lindsey Poulter, November 29, 2018
- Filter to Similar Items, Bethany Lyons
- Example 7 - Difference from Underlying Average, Bethany Lyons, November 1, 2018
- Example 5 - Range Comparisons, Bethany Lyons, November 5, 2018
- In Praise of BANs (Big-Ass Numbers), Steve Wexler, February 15, 2018
- Example 2 - Proportional Brushing, Bethany Lyons, November 1, 2018
- Sorting and Aligning on a Selection, Bethany Lyons, December 10, 2018
- Create Custom Drop Lines Using Set Actions and Transparent Worksheets, Lindsey Poulter, November 19, 2018
- How To: Dynamic Reference Band Using Set Actions with Tableau, Matt Chambers, November 13, 2018
- Set Actions - Reference Line Highlighting, Corey Jones, November 2, 2018
- Webinar for Tableau Software - Rich interactive analytics with Tableau Set Actions, May 23, 2019
- Action Analytics