Introduction
I use the “set” functionality in Tableau for a lot of different things. Â “Sets” are very useful to me and I am still trying to learning how to use them effectively in my work. Because there are multiple techniques for creating sets in Tableau, there might be better techniques available to control the set definitions in Tableau than I show in this post. Â Even if that is the case, I think this post will offer some insights to “set” behaviors that might surprise some Tableau users that use “sets” created from data marks.
A few minutes after publishing this initial post, Joe Mako wrote to me to tell me about a different technique for creating sets from filters rather than data marks, which solved the problem I originally described in this post. Â After reviewing what he said, I remembered that I used to use this technique but had forgotten about it! Â As usual, Joe was perfect in his analysis and lead to a solution for my problem. Â The final section of this post shows how creating a “set” from filters and now this blog post has a different meaning for me. Â What I have learned is that the method you choose to create your “set” can have a big impact on your ability to get the right answers if you have to update an analysis in the future. The first technique I show in Video 1 uses “sets” created from data marks (which has potential pitfalls explained below) and the second video shows “sets” created from a “filter”. Â This post changed direction within an hour or two after publication and taught me some valuable lessons on “set” creation in Tableau.
If you like this article and would like to see more of what I write, please subscribe to my blog by taking 5 seconds to enter your email address below. It is free and it motivates me to continue writing, so thanks!
General Set Definition
Ideally, when you define a “set”, you want that “set” to contain all the elements (or members) of the “set” that you originally define the “set” with. Â You probably do not want that “set” to change in any way. Â If I define a “set” called “coins” that includes members called “quarters”, “nickels”, “pennies” and “dimes”, I want those four members to be in that set at all times, regardless of whether my database has any data of the type “quarters” in it. Â My “complete set” should have four members in it for all future analyses. However, if my Tableau database doesn’t have any “quarters” in it on the day that I initially create the “set” from my data marks, my Tableau “coins set” will only contain three members and “quarters” will not be in the set definition when it is written to the *.twb file. Â This occurs when you choose to create the set using the data marks on your visualization as shown below. Â Just because “quarters” were not found today, doesn’t mean they will not be found tomorrow. Â Therefore by eliminating “quarters” from my “coins set”, there is no way for me get the proper analysis completed in the future using this “coin set” definition – I’ll have to add the “quarters” definition back to the set definition in the *.twb file to get the correct analysis. This simple example forms the first example of this post – creating a set using data marks.
Two Methods to Create “Sets” in Tableau
There are some things that Tableau users should know about “sets” that are not intuitively obvious and could eventually bite you if you are not careful. In the first video example in this post, I show a typical example of using “sets” that are created from data marks. Â There are a couple of interesting outcomes (and potential pitfalls) of this method as shown in the video (10 mins). In the second video, filters are used to create a “set” with a different outcome in the “set” definition compared to the first example.
Creating a “Set” using Data Marks, Video #1
Creating a “Set” using Filters, Video #2
Conclusion
Even though this post is not a comprehensive evaluation of “sets”, it does show you need to be careful in defining your “sets”. Your “set” definition as written to the *.twb file will vary depending upon the method you choose to create the set.  If you choose to create the set based on the data marks as shown in video 1, your “set” might not be the “complete set” that you thought you were creating. This has ramifications for Tableau files that are used in the future to evaluate updated data files.  If you choose to create the “set” based on a filter as shown in video 2, you will capture the “complete set” that you were intending.  These differences are important but are not necessarily easily understood without some investigation.
There are different kinds of Sets, in your video at 2:50 you created a Set based on marks. What you really want is a Set based on a Filter.
Instead of selecting the marks in the view to create a Set as you did at 2:50, right-click on the pill that is on the filter shelf and select Create Set from the context menu there.
Now the Set listed in the Data Window can be edited just like you would edit a Filter.
Hi Joe,
Thanks for reading and providing timely advice once again. I had forgotten about creating the sets from the filters!, although I have used this method many times in the past. I added a new section to the post to show the difference between the set creation methods, which actually makes the post more interesting. The reason that I write these things down in the blog is so that I don’t forget what I have learned! Now I know to avoid creating a set from data marks if I have to revisit the analysis in the future with updated data. As usual, your advice was right on target so thanks for your help.
Ken
Nicely Done Ken!
See also http://onlinehelp.tableausoftware.com/current/pro/online/en-us/help.htm#sortgroup_sets_create.html%3FTocPath%3DBuilding%20Data%20Views%7CSorting%2C%20Grouping%2C%20and%20Sets%7CSets%7C_____1 for the Tableau termonology, “Constant Sets” and “Computed Sets”
Thanks! Trying to find a fix for an issue with a set today, and this helped me a lot. Cheers!
Hi Kelly,
Thanks for writing and I’m glad that this article helped. There are so many details to learn about Tableau behavior that I like to document these when I learn them. I usually have to revisit my own articles to remember what I did!
Ken