Image from iStock
What are Sets?
Sets are custom fields that define subsets of data based on certain conditions IN/OUT.
Sets differentiate the data in the viz. through In/Out notations without aggregating data.
You can create a set by selecting members from the list or a visualization. You can also do the same by writing custom Conditions or Selecting the Top/Bottom few records in a Measure.
Types of Sets
Static/Fixed Sets: The members of a fixed set do not change. A fixed set can be based on a single dimension or multiple dimensions.
Dynamic Sets: The members of a dynamic set change when the underlying data changes. Dynamic sets can only be based on a single dimension.
Combined Sets: It is a combination of two sets to compare the members. When we combine sets we create a new set containing either the combination of all members, just the members that exist in both, or members that exist in one set but not the other.
Let's Start Creating Sets
For creating Sets in Tableau I am using sample superstore data
Let's start with Fixed Sets
I am creating a viz. using two dimensions category and sub-category in rows with the sale in labels
Image by author
Now for creating a Static Set I am manually selecting a few sub-categories by cont+select and then we see a drop menu with a set sign when we click on create set we will see these selected sub-categories will fall under the same bucket and others will another bucket which is In or Out
image by author
Image by author
If we don't select exclude in the above picture then our static set is In set, it includes the sub-category we have selected, and we can find our set in the data pane like this
image by author
Now when we put this static set in color under the mark card we will find it like this
image by author
You can see that In part of the set is highlighted with blue and Out is highlighted with grey. This is a Static set because we created it manually its value is not going to change until we manually do it again.
2. Dynamic Set
For this, I am creating a viz. with a single dimension that is sub-category-wise sales
image by author
and right-clicking sub-category we can see create an option in which the set option fall, this is the way to create a dynamic set
when we click on this we will see 3 tabs
General
Condition
Top
while creating a dynamic set we use mainly condition and top tabs but we select "USE ALL" in the General tab so that even if the new data comes in later, it will be part of this set.
image by author
following this selection in General we move to Condition or Top tabs depending upon our requirement, I am creating a Dynamic set by using the Condition tab, you can also create it with Top like top 3 or top 5 sub-category-wise sales.
image by author
Here I put a condition that I want a set of sub-categories with the sum of sales > 50,000, Now let's see how it will look in our viz. when we put this set color under mark card as color
image by author
Here items of sub-category that falls under our condition are shown in blue color (In) and the rest in grey color(Out), as this is a dynamic set the member of the set will change if the underlying data changes later
We can also use this set as filters if we want
3. Combined Set
Let's create a scatter plot by putting the sum(profit) in a column and the sum(sales) in measure with Product Id in detail under the mark card and remove the outliers
image by author
Now using Product Id as a dimension we will create two dynamic sets
sum(sales) with a condition like the above we created by selecting "Use all" in the "General" tab and then using "Condition" tab to put our desired condition as "High sales products".
sum(product) as "High profit products"
Now to create a combined set, we will select the two sets which are created using the same dimension which is "Product Id". Right click then select create combined set as shown below:
image by author
Now when we click create combined set option we will get the option to create a set like this
image by author
After naming it we will see the sets name which we are combing and 4 options with different types of intersection, here I am choosing the 2nd option which is "shared member in both sets" and by clicking ok we will create a combined set.
Now let us look at it in viz. when we put this combined set in color it shows whichever product is in my set with blue color and the rest with grey.
image by author
This is how we create Static, Dynamic, and Combined Sets in Tableau
Key to remember
Static Sets are multi-dimension, Dynamic sets cannot be created with more than 1 dimension as it is based on a single dimension.
Measures do not give the option to create a set, however, measures are used as a condition while creating a set out of the dimension.
While creating Combined Set both sets have to be created on the same dimension otherwise we won't get the option to create a combined set.