Are you getting started with Tableau and looking to create a set? Well, you’re in the right place.
In Tableau, a set is a temporary table that is generated based on specific criteria or conditions defined by the user. It is a subset of data that you can use for analysis and visualization without altering the original data source.
In this article, you will learn about sets, use cases, and their advantages in data visualization.
Let’s jump in.
What is a Set?
Firstly, a set is a subset of a data source created by defining a set of conditions or selecting a group of data points from the data source.
You can create a set by dragging a field to the “Sets” shelf, where you can define the set’s conditions and characteristics.
Tableau provides two major types of sets:
Normal Sets: These are sets created from a single field and allow you to categorize data points as either members or non-members.
Combined Sets: These sets are created by combining multiple normal sets and can be used to perform set operations like union, intersection, and difference.
How to Create a Set in Tableau
In this section, we’ll learn how to create sets in Tableau.
Specifically, we will learn the following 4 methods of creating a set:
Creating a Set from the Data Pane
Creating a Set from a Visualisation
Creating a Set from the Top or Bottom N Items
Creating a Set from Calculated Fields
1) How to Create a Set From The Data Pane
In the Data pane, right-click (control-click on Mac) a dimension and select Create > Set.
In the Create Set dialog, you can specify the conditions or manually select the members for the set.
When done, click OK and a set will be created.
2. How to Create a Set From a Visualization
In a worksheet, you can create a set based on a selection of marks in a visualization.
For demonstration, we have the following bar chart with sales by State. We want to create a set of the first 3 states.
To create a set, select all the marks that you want to put together in a set.
In the context menu, click on the set icon.
A set configuration menu will appear. Click OK to create the set.
After clicking OK, the set will be created, and you can see it in the dimension tab in the data pane.
A set created through this method is also known as a fixed set as they are not changing.
3. How to Create a Set from the Top or Bottom N Items
Creating a set from the top or bottom N items in Tableau is a useful technique when you want to focus on a subset of your data that represents the highest or lowest values according to a specific measure.
Choose a dimension or measure of your desire and select Create > Set from the context menu.
This will open up a set configuration menu. Assign a meaningful name to your set.
By default, the dialog box opens to the General tab. Click on the Top tab to access the settings for creating a top or bottom N set.
Select Top to create a set of the top N items. Select Bottom to create a set of the bottom N items.
Enter the number of items you want to include in your set. For instance, entering “10” will create a set of the top or bottom 10 items.
Choose the field that the top or bottom N will be based on (e.g., Sales) and decide how it should be aggregated (e.g., Sum, Average). This is the measure that will be used to evaluate what constitutes the top or bottom items.
Your final configuration will look something like the following:
After configuring your set, click OK. The set now appears in the Sets section of the Data pane.
4. How to Create a Set from Calculated Fields
Creating a set from a calculated field in Tableau allows you to create a dynamic set and define the members of the set based on a custom condition or calculation. This method is particularly useful when the logic for defining the set is not straightforward or requires a custom formula.
The method for creating a set from calculated fields is similar to the previous methods, the only difference is that you need to create a calculated field first.
Right-click on the drop-down menu in the Data pane and select Create Calculated Field.
Write a calculation that returns a boolean result (True or False).
For example, a calculated field might be defined to return True for sales above a certain threshold or for a specific category of products.
After you have your calculated field, you can use it to create a set. Right-click (or control-click on Mac) on the calculated field in the Data pane.
Select Create > Set. This opens the Create Set dialog box.
In the Create Set dialog box, give your set a meaningful name.
Only the members of the set are defined by the calculated field, so you won’t have to manually select members as you would with a normal set. Instead, the dialog box will show the formula of your calculated field.
You can see a preview of the members that will be included in the set based on the current calculation.
After reviewing the set configuration, click OK. The new set, based on the calculated field, will now appear in the Sets section of the Data pane.
Sets created through this method are also known as dynamic sets.
What Are Set Actions?
Set actions are a powerful feature in Tableau that allows you to dynamically interact with your data visualizations.
When you create a set in Tableau, you have the option to perform set actions.
Set actions allow you to apply changes to a set by interacting with the visualization.
The most common set actions are:
Add to Set: Adds the selected data points to the set.
Remove from Set: Removes the selected data points from the set.
Let’s look at an example of each of the above set actions.
Example of Adding to Set
We have a bar chart displaying sales by state.
We’ve created a set that initially includes a few top-performing states based on sales, and we want to add more states to this set by selecting bars in the bar chart.
The set selected represents multiple dimensions of your dataset, depending on how the members are analyzed.
Click on the state you want to add to your set.
In the context menu, click on the set icon and then select Add to State Set (name of your existing set).
Example of Removing From Set
To remove from a set, click on any state that is currently in your set.
In the context menu, click on the set icon, and then select Remove from State Set (name of your set).
This set action is particularly important when you have to separate members that are not relevant in your current set.
Learn how to create demo data to use in Tableau using ChatGPT by watching the following video:
Final Thoughts
Sets in Tableau are an invaluable tool for data analysts and visualization designers.
They enable you to work with groups of data that share common characteristics, making it easier to compare, analyze, and visualize information.
By understanding the different types of sets, such as normal sets and combined sets, you can create subsets of data that are meaningful and relevant to your analysis.
Furthermore, with the power of set actions, you can create interactive dashboards that allow users to dynamically explore and gain insights from the data.
Remember, sets are not just static groupings of data, but also a way to filter and highlight information. Sets represent multiple dimensions of your data and analysis.
So, whether you are working with attribute sets, measure sets, or combined sets, Tableau’s sets feature will help you unlock the full potential of your data and create compelling visualizations.
Frequently Asked Questions
In this section, you will find some frequently asked questions you may have when working with sets in Tableau.
How do you create a set in Tableau Desktop?
To create a set in Tableau, follow these steps:
Right-click on a dimension in the view or the “Data” pane and select “Create Set”.
In the set control dialog, define the set’s conditions and characteristics.
Click “OK” to create the set.
What is the difference between a set and a group in Tableau?
A set in Tableau is a subset of data that is defined by a set of conditions.
A group is a way to combine multiple members of a dimension into a single group.
The main difference is that a set is dynamic and can change based on the data, while a group is static and does not change even if the underlying data changes.
How can I edit a set in Tableau?
To edit Tableau sets, follow these steps:
Right-click on the set in the “Data” pane and select “Edit Set”.
In the set control dialog, make the necessary changes to the set’s conditions and characteristics.
Click “OK” to save the changes.
What are some examples of set actions in Tableau?
Some examples of set actions in Tableau include:
Adding data points to a set by clicking on them in the visualization.
Removing data points from a set by clicking on them in the visualization.
Toggling the selection of data points within a set by clicking on them in the visualization.
Highlighting data points within a set by hovering over them in the visualization.