More fun with sets

by Damiana Spadafora

The topic of today is sets. We use them all the time but do we really know what we can do with them? I have talked previously about how I am digging deeper into everything Tableau related in view of taking again the Qualified exam and the last thing I have mentioned is that there are two different kinds of groups.

You might hear that sets are like group, well it’s more like sets are groups on steroids. Or, if you prefer, you put things in items and you put things in groups and that is where the similarities end. Here are three things you can do with sets that you cannot do with groups:

1. Sets can be joined into combined sets

Creating a combined set is really easy. Just select the two sets you want to combine, right click and choose Create Combined Sets. What is interesting is the window that pops up:

Combined Set

Here you can choose how you want to combine those sets: you can select all the members in each set, limit the selection to only those that show up in both sets or exclude the shared members from one set or from the other. In this case it is used to show only the customers that have the highest sales and the highest profit but it can be adapted to all sorts of needs.

You cannot create a combined set with more than two sets, but you can use combined sets to create another combined set, Tableau doesn’t mind and it’s going to work exactly as if it was a normal set. At this point go ahead and create a “Set-ception”, as long as you’re prepared to dealing with the consequences.

2. Sets can be used in calculated fields

Sets can be used in calculated fields as if they were a field. In the picture below I have created a field that will show me values only for the members belonging to that set.

Calculation Set

Or you can have the calculation return a specific value, or return another field instead, the main point is that they are not very different than normal dimensions in this respect.

3. Sets can be used across data sources

This is a bit more complicated. Say that, for example, I wanted to use a set from a secondary data source as a filter for a graph I have created with my primary source data. This is what I will see:

Sets grayed out

The sets from the secondary source have been greyed out and cannot be used. But there is a way around. What I’ve done is to create a calculated field in the secondary data source that returns “In” if the field belongs to that set and “Out” otherwise.

Calculation for filter

You can now use this as a dimension and add it on the filter mark and choose whether you want to show “In” or “Out” values, you can put it on colours and then colour code your map accordingly.

Colour Coded by Set