Sets in Tableau

Tableau sets enable you to separate certain sections of a dimension, that afterward can be used in several different methods to locate powerful insights in the data that you have collected. This article will provide instructions on how to develop sets from scratch as well as 5 various ways how those sets can be utilized to improve your analyses.

excited multiracial colleagues enjoying triumph together in front of laptop in office
Powerful Sets for Dynamic Tableau Logics

Sets, in other words, can be thought of as custom-made segments. However, unlike dimension fields, they are always binary. That being said, the dimension is either in the set or otherwise, there is no other possible outcome. Other than that one drawback, sets can be developed for practically anything. You can manually choose individual members of a dimension to be placed in a set, have actual sets be based upon quantitative thresholds, create a set that will indicate the top or bottom performing members of a certain dimension, and many more. 

So as a summary, Tableau sets are just custom fields that will present a certain subset of data based on a condition that you set upfront. Sets can be created by selecting members of a dimension from a list or a visualization. You can also create sets more dynamically, by writing Conditions or selecting Top/Bottom performing members based on a certain Measure. 

Let’s find out how to create Sets in Tableau and what are the most common ways to utilize them.

How to Create Sets in Tableau

Similar to developing filters in Tableau, there are many different ways how you can create sets. The initial and also the most straightforward way is to simply present a certain dimension on a view using visualization and then just, select a few members of that dimension. So once you have your dimension displayed, you can manually select a few members of it and hover over one of the bars. A little pop-up window will preview, where you should choose the Venn diagram icon that appears. Choose ‘Create Set…’. Here’s what our outcome would look like if we aimed to develop a set that will display the top 10 customers by sales in the Sample – Superstore data set.

After we click on “Create Set …” and give the set a relevant name, the newly created set will show up on the Sets Shelf on the left side of the Data Pane. This set that we have created now, which gives us information whether the customer is in or out of the top 10 consumers by sales, is now offered and ready to be utilized in our further analysis. Keep in mind that sets developed with this approach are fixed, so the top 10 will certainly not dynamically alter ought to once a new customer enters the leading 10. 

Another way to create a set is by right-clicking on the dimension on which you want to base your set. Hover over ‘Create’ and choose ‘Set…’. A new dialog box will appear: 

In this dialog box, you can see that there are three tabs, each of them giving you a different opportunity to develop your set. In the very first tab, ‘General’, you can manually pick and choose which members from the dimension should be included in the set as we have done in the previous approach, manually picking members from a visualization. Here we have the same drawback as in the first method above. When we create a set by manually picking its members, we are making this set fixed. That being said, this set will not automatically change if a new member is added and that member should be included in the top 10. Using these methods of creating sets is applicable in situations where the members of the dimension on which you are basing your set are not expected to change. Or at least, not frequently. For example, if your business is operating in multiple countries for a few years, you can easily create a set from the countries in which you are operating. Since expanding your business in a new country can present a somehow more complex process, the members of this dimension should not change frequently. Even if they change from time to time, you can easily enter the set and add the new countries, if needed.

The second tab, ‘Condition’, provides you with an opportunity to create a set that will only hold members of a dimension based on a condition that you have stated upfront. That means, every member of the certain dimension that fulfills the condition that you have stated, will automatically be in the set. Otherwise, every member that does not fulfill this condition will not enter the set. Creating your set based on a condition is applicable in situations where you want to filter, or in other words to create a subset of your data, based on some rule. For example, since the Customer Name list can usually present a long list of names, you are probably more interested in analyzing the behavior of the customers that made purchases of more than 100$ than of those that made just one-time purchases of 2-3$. In other words, to put your focus on your more loyal customers and analyze some of their customer habits. In this case, you can create your set by stating a condition to include only customers that have sales higher than 100$. 

And the last tab, ‘Top’, enables you to create a set that will display only Top N Performers. Like in the example above, if you want to focus your analysis on the Top 10 Customers that were responsible for most of the sales, you should create your set using this tab. In this tab you can enter the number of Top N performers that you want to display that will stay fixed, or you can choose to use a parameter instead and have the opportunity to change the number by yourself using an interactive control on your dashboard. Be sure to check our article Top N vs Others (hyperlink of the article that I’ve submitted before for Top N vs Others) where we give a full tutorial on how to utilize the benefits of sets, parameters, and calculated fields together in order to analyze your Top N Performers. 

Please note that creating sets using the two previously explained approaches will be dynamic, which means that they will automatically update once the data is being upgraded. 

Five Ways to Use Sets in Tableau 

Sets can be used in many ways in order to answer complex questions and compare subsets of data.

  1. As a filter

One of the most common ways to use sets is as a filter. You can use your sets as a filter by right-clicking on the set from the Sets Shelf and choose the option ‘Show Filter’. As we said in the beginning, unlike the dimension fields, sets are binary. That means you can only choose to see the members which are included in that set or the members that are not included in that set. You can use your set as a filter on a simple view where you display all your customers as we had above when explaining how to create a set from a visualization. By placing your set as a filter, you can choose if you want to display only the Top 10 Customers or all others that are not included in this set. Here is how our bar chart of sales by Customers in descending order looks after showing the filter ‘Top 10 Customers’ on the side and choosing to keep only the customers that are in the set. 

Another way how you can use your set as a filter is to create a view that will show multiple measures ( for example Sales, Profit, Quantity) over time and choose the newly created set as a filter. This way you will modify your charts to be relevant only for members of the set instead of being relevant for all. This way you can get more insight into the customers that you are focused on. Here is an example of how you can create your view and use your filter properly. For this example, we will be using the set that comes with the Sample data, Top Customers By Profit. In the screenshot above you can see the Sales, Profit, and Quantity for the Top 20 Customers by profit for the last year. 

  1. To encode marks
  2. Another way how you can use sets is to encode marks on a view. In other words, to highlight the members of the set in visualization and make it easy for them to be spotted. You can do this by dragging the set that you have created to the Color Marks Card. Here is an example where the top 10 customers by sales stand out on a scatter plot.

3. In calculated fields

You can use sets in calculated fields similar to dimensions or measures. By including a set in a calculated field, you can deal with the members of a dimension differently based on whether or not they are in a set. 

For example, let’s say that you’ve created a set that shows Top 10 Customers by sales. If you place the set that you have created on the Rows Shelf, and Sales on the Columns Shelf, you will get just two bars that will display total sales for the members included in the set and the members who do not belong to the set.  

If we add the field Customer Name next to the set on the Rows Shelf, under both categories, In and Out, we will get all the names of the Customers who are included in the set or are out of the set. 

But what if we want to have an option to preview the names of the customers that are included in the set, and group all other customers in the category ‘Others’? This can be done easily by creating a calculated field and connecting it with a relevant parameter. 

First, you should create a parameter that will serve as an interactive control on your dashboard and will allow you to choose if you want to expand the names of the customers under ‘Others’ or just keep them under one category. For the data type of the parameter choose String and for Allowable Values choose List. Next, write the two options that this parameter will contain, Expand, or Collapse. 

Once we have created the Parameter, we can create the calculated field that will connect the parameter and the set. This calculation will allow the viewers to specify how to display the customers in the Others subset. Select Analysis, and choose Create Calculated Field. Once you have the Calculated Field box opened, type the following formula. 

IF [Expand or Collapse]=”Collapse” THENIF [Top N Customers by Sales]THEN [Customer Name]ELSE “Others” ENDELSE [Customer Name] END

With this formula you are saying that every time the Collapse option is selected in the breakdown, only the names of the Top 10 Customers should appear, while all others should be grouped under Others. On the other hand, every time the option Expand is selected all Customer Names should be displayed. 

Now place the newly created Calculated Field instead of Customer Names on the Columns Shelf. Here is an example of how our view looks like when we have selected Collapse in the Parameter.

4. As dimension fields

Once created, sets can act as individual dimensions by themselves. For example, for the scatter plot that we have created above, we can present it from another aspect. Instead of highlighting the top 10 Customers on the same scatter plot, we can create two – one for the top customers and one for the others, not included in the set. So, here is how our view will look like if we create two separate columns for members included in the set and for members not included in the set by dragging the set to the Columns Shelf.

5. Within a custom hierarchy

One of the cool things about sets is that they can also be utilized as a part of a custom hierarchy in Tableau, which allows you and also your end-users to quickly and easily drill down and also back up across various dimensions.  This will add make your hierarchies dynamic, especially if you nest multiple computed sets into one hierarchy. For instance, you might intend to create a hierarchy with customer names that begin with the Top 10 Customers by Sales set, then drills down to specific customer names, then to their segment. 

First, in order to create a custom hierarchy, we should choose the Customer Name and also the Segment dimensions, right-click on them, hover over “Hierarchy”, and then choose “Create Hierarchy…”.  So now, we have created a hierarchy that includes only the dimensions Customer Name and Segment. In order to add the set Top 10 Customers to the hierarchy that we have created, we need to drag the set to it and then rearrange the hierarchy for the desired order. 

Now that we have our hierarchy created, we can replace the Customer Name field on the Rows Shelf with the set Top 10 Customers. Now we are able to drill down from the Top 10 Customers to Customer Name and then to Segment. This can be accomplished by clicking on the plus symbol ‘+’ on the fields on the Rows Shelf.

This is how your view will look like if your hierarchy is not drilled down. We have two bars for each group of the Set and the total sales for each of them.

Once we have expanded the hierarchy for one more dimension, right next to the groups of the set we can see the Customer Names which are included in the set ( under In ) or excluded from the set ( under Out ).  

And now since our hierarchy is expanded to the fullest, we can see the sales by the set, the customer names, and the segment in which the customer is in. 

Protip – How to Combine Sets in Tableau

As we said before, sets present custom-made segments of a given data. By creating sets you are grouping the data the way you want it and the way it fits your analysis. But what If you need to combine two sets in order to answer some more complex questions or give your analysis an upgrade? Fortunately, Tableau allows you to combine two sets in order to compare its members. When you are combining two sets in Tableau you are creating another new set that will either include all members of both sets, just the members that exist in both, or the members that are available in one of the sets but not in the other. Just try to imagine what kind of insight you may get while combining two sets. Please note that in order to be able to combine two sets, you must base them on the same dimensions. That being said, you can combine two sets that include the top customers but you can not combine sets where one of them includes the top costumers and the other one the Top States. 

Let’s go step by step how you can combine sets.

  • First, in the Data Pane, select the two sets that you aim to combine. 
  • Once you have your sets selected, you should right-click on them and select Create Combined Set.
  • A new dialog box appears. Here you should type a relevant name for the new set that combines the already two existing sets.
  • Confirm that the two sets that you wish to combine are selected in the two drop-down menus.
  • Now, you should select one of the three following options which will indicate how you want to combine the sets. If you choose All Members in Both Sets, you are stating that you want your newly combined set to include all members of both sets. On the other hand, by choosing Shared Members in Both Sets you are enabling your combined set to include only the members that are available in both sets. And last, if you choose Except Shared Members you are actually allowing your combined set to include only members that appear in the specified set, but don’t exist in the second one.

These options when looked at from another aspect, present subtracting one set from another. For example, if the first set contains New York, California, and Philadelphia and the second set contains California and South Carolina; combining the first set except the shared members would contain just New York and Philadelphia. California is removed from the combined sets because it is available in the second set as well. 

Summary

In this article, we learned that sets present a subset of the data that we have. With sets, we can organize the data in a way that fits our needs. In Tableau, there are various ways how you can create sets. You can create them manually by selecting certain members of a dimension from a view or a visualization. These sets are considered as fixed sets because they won’t update accordingly even if the data behind them is being updated. On the other hand, we can create a dynamic set that we can base on a certain condition. These sets are being considered as dynamic because they will update automatically is there a new member that needs to enter the set. 

Using the sets for your benefit can be done in various ways in Tableau. You can use the sets as filters, to encode marks,  in calculated fields, as individual dimensions fields, or within a custom hierarchy. 

You can also combine sets to add additional functionality to your data and use the new combined set to ‘open’ new insights. In order to combine two sets, you got to make sure that the sets are based on the same dimensions. Otherwise, you won’t be able to combine them. When creating a new set you can either choose to include all members that appear in both sets, members that are available in both sets, or members that appear in one of the sets but not in the other one.

excited multiracial colleagues enjoying triumph together in front of laptop in office
Tableau Date Functions

By the Editorial Team

cheerful surprised woman sitting with laptop
Tableau Advanced Sets

By the Editorial Team

amazed formal male looking at laptop screen
Tableau Parameters

By the Editorial Team

portrait photo of excited man in blue t shirt standing in front of white background
Tableau Color Choices

By the Editorial Team

Tableau Practice Test

The best Tableau practice exams built. Period. Explore definitive practical problems created by brilliant Tableau experts.