Set Control: Default Trickery

Filippos Lymperopoulos
8 min readMay 4, 2020

--

I first publicly demo’d the Set Control feature at Devs on Stage during TC19. It is my favorite feature of the upcoming 2020.2 release, and it is going to be a game-changer.

Two weeks ago I posted a blog discussing the new enhancements coming soon to Set Actions in 2020.2 and ended the post saying:

With Set Actions and the Set Control we always edit the selected values in the set dialog’s General tab. The same holds true for quick filters, of course, this is no new behavior. There is, however, one exception to this rule that I will outline in a future blog post!

In this blog post I will show you that exception. With it you can computationally define what values are selected in the Set Control. In other words, you can define its default behavior to whatever condition you want!

Condition and Top clauses can define control selections

Disclosure

This method is considered an advanced “hack” trick but a very valuable one nonetheless to be aware of. The Set Control feature available soon in 2020.2 works exactly like all other Tableau controls you have been used to over the years. This blog highlights a mismatch between Tableau’s platform and UI that can be beneficial if someone wishes to explore it :)

Background

One way to think of sets is as named filters that can be used in calculations. As such, Set Controls look exactly like Quick Filter controls. Both controls are very easy to understand. You select some values and the view updates to reflect information for the selected data values.

In the case of a conditioned filter or set on the State field, i.e. Top 2 States by SUM(Sales), the control looks a bit different. Instead of showing you the 2 States with the highest sales selected, it shows all State values in the control selected, by default, and the Top 2 condition written at the bottom. Tableau assumes, by default, that you want to look at all State values in the field’s domain (thus all selected) and from all the States find the 2 States with the highest sales values.

So what happens when I unselect values in the controls above? Tableau updates the selected values in the set’s or filter’s General Tab and then applies the condition to the new set of selected values. For example, if we were to select only 4 States, Tableau would return the top 2 States by Sales from the selected 4. While it is beneficial to programmatically control what values the filter or set will load with when the workbook opens, it is impossible for viz consumers to arbitrarily change that during analysis. This is problematic, as I can never ask a question about 1, 3, or any number other than 2 States.

Feature Improvements

Over the years, we have not altered how conditioned controls display or work. We have, however, added more programmatic control in specific scenarios. Discrete Date Default Value Filters (DVF), also known as Filter Presets, is one such example.

The DVF feature, shown in orange above, allows an author to set their discrete date filter selection to the maximum date value in the date field’s domain. As such, it also allows viz consumers to change that to an arbitrary set of dates as they interact with the viz.

Latest date in the data source is 12/30/2019

Before DVF, authors were able to create a workbook that launches with data for just the latest day/month/year, using the Top tab’s “By field” affordance.

Doing so, however, resulted in a control on which viz consumers were unable to select an arbitrary number of date values. It always returned the max date for the date values selected.

DVF is limiting: single value and only available for discrete date fields.

Enter sets.

Set Control

General Tab w/ Set Actions and Set Control

Think of a Set Control as a Filter Control only better. I have written and talked about the differences between filters and sets before, and the complex things you can do with them, but for purposes of this walkthrough I’ll keep the example very simple.

We will use a set to color a simple scatter plot and customize its default state. Currently the set contains the Top 2 States by Sales in the Sample US Superstore dataset (Texas and New York). For now, I have removed all California rows from the data. We will bring them back in at the end.

As described above, if I uncheck values in the control, Tableau always applies the top 2 condition on the remaining selected values. As shown below, nothing changes in the view because Texas and New York are still the States with the most Sales.

I can do the same thing with Set Actions and the control behaves like you’d expect.

With the Set Control and Set Actions in 2020.2 (Assign, Add, Remove) we are always editing the data values in the General tab of a set’s definition (on which the conditions apply). Everything works as you’d expect.

Add/Remove from Tooltip

Notice what happens though to the control when I use the legacy Add/Remove option from the tooltip’s command menu.

Take a look at the GIF above. What just happened? Tableau removed the condition and shows me the set’s previous values (New York, Texas) plus the new value I added visually (Washington) as selected.

If we go look at the set’s dialog the condition is gone, as the orange rectangle shows below and the number of States in the set are 3.

But, is the condition really gone? And are the States in the set 3 or 2?

Twb Representation

Let’s open the .twb file to see the definition for that set.

Notice that the condition is actually still there. The group of nested groupfilter tags shows this below.

And not only that, but the new visually added data value is also there.

In other words, this set is now a union of a conditioned set of values (our original set, i.e. Texas and New York) and an arbitrary value (the visually added value, i.e. Washington).

We don’t have a way to display such a set definition for a single set in Tableau’s UI today, so we remove the condition from the set’s dialog and control, making you think it’s gone. We refer to this set as being “flattened.”

Now I can remove Washington, the value I just added, and end up with a set whose values are only the ones returned from the Top 2 condition. The set now has the same values we started the example with but its control looks different.

Here’s how the twb definition looks now. Notice the “except” clause that removes Washington after it was added.

The magic here is that as my data updates, so will the selected values in my control!! By following these steps, I could specify any arbitrary condition and my set will always default to selecting values that match that condition. Sets can be used as filters, as encoding indicators, in calculations, and more. With this trickery, the set control becomes a default multi-value multi-purpose control.

Add California rows back to the data set

Now that we saw how it works under the covers, let’s see what happens when I add California back to the data set.

Notice that California and New York are now encoded as blue in the viz AND selected in the set control after the data source is updated! The Set Control will show the top 2 States by SUM(Sales) selected in the control and your viz consumers can change that to whatever other selection they want when they interact with your viz.

Gotchas

There are, of course, gotchas with this approach.

The set definition in the twb will be intact and the set’s behavior consistent if the workbook is saved and published as we left it, shown below.

This advanced “hack” trick is, however, quite fragile. If an author edits the set from the set’s dialog, the set control, or a Set Action to add a new State, i.e. “New Mexico,” notice what happens to the twb.

The condition is gone. Tableau doesn’t know how to edit this new type of “unioned” set we created. As such it assigns the latest selected values to the set’s General Tab definition when the workbook is saved and ignores previously defined conditions.

This editing is not an issue on the consumption/interaction side, since the set edit does not persist to the twb for future consumptions of the workbook.

I realize this is a lot of information so please let me know if you have any questions! More posts to come soon :)

--

--

Filippos Lymperopoulos

Product Manager @tableau; formerly @edXOnline and @ericsson | @OlinCollege