Tableau Groups vs Sets
The difference between Tableau’s Groups and Tableau Sets was something that confused me a little when first started with Tableau. Tableau groups seem pretty self-explanatory, but sets seemed a little complicated. Grouping in Tableau is grouping multiple members/values into several groups which will create a higher category of the dimension. Creating a set in Tableau is putting multiple values IN my a single set depending on a condition or by manually picking them. In a set you have two options, you are either in my set or out my set.
We are going to start with a basic group. I am working with the Sample – Superstore data that comes with Tableau so you can follow along with me. First thing I am going to do is bring Sub-Category over so I can see what all the Sub-Categories are in the data. Now in this data, there is already a higher grouping of this field called Category but we going to act like this does not exist. Now that we have all the values out there let’s go ahead and hold CTRL and select all the values we want to be in the first group. In this first group, I want to group the values Bookcases, Chairs, Furnishings and Tables. Once all of them are highlighted hover over one of the selected values and click on the paperclip that shows up in the dialog box.
When we do this Tableau will automatically create a new dimension adding (group) at the end of the name. It is important to know that Tableau does not do anything to the original dimension, it is creating a new dimension based on how you are grouping values in the original dimension. Now we have the first group done let’s go ahead and create another group by holding CTRL and selecting Appliances, Art, Binders, Envelopes, Fasteners. Labels, Paper, Storage, and Supplies. Lastly lets group all the other values together by using the same method. In the end, it should look like this.
Now we have all of our groupings completed we need to rename them to something that makes sense. Lets right click one of the new grouping values and click Edit Alias. This will open up a box where you can rename the value of that grouping. Change the Alais of the group with Accessories in it to Technology, change the one with Appliances in it to Office Supplies and change the on with Bookcases to Furniture. Let’s go ahead and add the original Sub-Category dimension back to the rows so we can see how everything turned out
Tableau Groups – Custom Maps
Let’s go ahead and do a new example but this time grouping values in a map instead of a text table. We can create the map by double-clicking on State. Once the Tableau map is rendered, we will change the mark type to Map so that we can see it as a filled map.
Next, we will want to select individual states as you see in the picture below by either selecting individual states by holding CTRL or by selecting multiple by clicking and dragging to create a selection box. Select the States I chose below and then click the paperclip to group all those states together in a group.
Now we have our first grouping which created a new field called State (group). The goal here is to group the States into four different regions; we got one down now we have three more to go. Next click on the States you see selected below and group those as well.
Now we have the last grouping we will have to do because all the other States will be bucketed into an “Other” group. So go ahead and do this final grouping by selecting the States you see below and group them together.
After you do that last step, your map should look like below where we have four different colors which are our new regions. We now have to rename these groups as we did before by editing the Alias. Let’s click on each value in the color legend and change them to the region name you see below.
Since our group is made up of the geographic role State, it inherits its geographic role as well. So we can now remove State from the view and color our regions by our new region field. You will see now that we have a nice clean map with our custom regions mapped out. All we have to do now is rename our new group field to Regions and add this new Region field to the Labels. Below is what we should get.
Let’s go ahead and jump into Tableau constant sets now. Sets are very similar to groups which is why there is so much confusion. Think of a constant set as a restricted grouping or a binary grouping. In a set you have two options, you are either IN my set or OUT my set. We can manually select who is in my set or dynamically do it by some sort of logic. Right now we are going to talk about manually picking who is in our set. Once we put those values in our set when can then use that set in other vizs to analyze those values.
We are going to do an example together so you can see how it’s done. Let’s create this scatter plot as you see below. Drag profit to rows, sales to columns and Sub-Category to the Detail mark card.
Once we have this view, we can easily see who our high sales and profit Sub-Categories are by looking at the top right-hand corner. Let’s grab those 6 Sub-Categories and then hover over one of them till you see the same dialog box we got when doing the groups.
Hitting the set icon will group all those values into a set and then put all the other values “Out” my set. So anything we selected is IN our set, and everything else is OUT our set. In the screen that pops up, we can see the values we chose and name the set we just created.
Now I can quickly identify who is in my set and who is out my set by dragging my new set field to colors.
Now that we have the set we can use this set in another analysis. For example, let’s say we want to figure out what we are doing differently with these high sales and high-profit Sub-Categories that we are not doing with the others. So let’s go ahead and see if we are giving a more significant discount with these Sub-Categories compared to all the other ones. Below I created a quick time series looking at our sets average discount over time.
Here we can easily see that the Sub-Categories in our set have a substantially larger discount compared to the ones out my set. Maybe we need to start offering a more substantial discount for all the others also? As you see sets are great for an ad hoc analysis but be careful because when you update your data, your sets will not update so it’s better to create a dynamic set if you will be using it ongoing.
Tableau Dynamic Set
The Tableau constant set is excellent for a quick ad-hoc analysis, but if you are going to be updating your data, then you need to do a dynamic set based on a condition. This will update your set based on whatever condition you entered. Let’s create a simple text table looking at profit and sales for each Sub-Category.
Our goal here is to also group our high sales and high-profit Sub-Categories into a set, but instead of manually selecting our values we are going to create conditions for them. Let’s say we only want Sub-Categories to be in our set if they have positive profits and sales over $100k. We could grab these manually like we did before or we can create a dynamic set.
We will create a dynamic set by right-clicking Sub-Category and selecting Create, then Set.
This will open up the create set screen where we can once again manually group values or do it dynamically by a Condition or Top Condition. Lets select Condition and hit the radio box By Field. Here we will put our condition, for the first one we will do the sum of profit > 0 and name this Profit >0.
Now we are going to do the same process and create a new set but this time do the sum of sales > 100,000 and name this set Sales > $100,000.
We can now put both of these sets in our view so we can see which Sub-Category meets each sets condition. We could put both of these sets in the filter shelve, and it will filter the data to just the Sub-Categories that are IN both of these sets, or we can create a combined set.
Lets right click one of the sets we created and select Create Combined Set. In this example, I only want this set to be IN if both of the other sets are IN.
Let’s drag this new combined set out to the view, and you will see this set is only IN when both of the other sets are IN.
We can now use that set in a scatter plot like below, and you will see all the Sub-Categories that meet this condition will be IN my set, and everything else is OUT. Now the cool thing about this is as the data updates so does the set, so you can now use this set forever without it being outdated.