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 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, irregardless 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
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 were intending. These differences are important but are not necessarily easily understood without some investigation.