Online tableau training, tableau tips, & video tutorials

Technical Features

Memberships

An Introduction to Tableau Sets

Preview

Instructor

Ryan Sleeper

Reveal New Insights by Creating Customized Segments and User Experiences

You’ll learn how to: (1) create static sets, (2) create dynamic sets, (3) use sets as a filter, (4) use sets a dimension, (5) use sets within a calculated field, (6) add a set control, and (7) use dashboard set actions.

Hi, this is Ryan with Playfair Data TV. And in this video, I’m going to provide an introduction to sets in Tableau. I’m going to show you two different ways on how to make sets, and then I’m going to show you how to use sets as a dimension, as a filter, within calculated fields. I’m also going to show you how to use a set control, and I’m going to show you how to use set dashboard actions.

So over here in Tableau Desktop, if you’d like to follow along I’m using the Sample Superstore dataset. The first thing we’re going to do is create a set. Sets are called that because we’re creating a subset of dimension members that we can treat in different ways. So for this first example, what I’m going to do is create a subset of our customers. And you can create a set out of any dimension members, but just to throw out one use case, let’s say that we want to isolate our top 10 customers by sales into their own set.

To do that, I’m going to drag Customer Name onto the view, and make a quick bar chart that looks at sales by customer name. I will also sort this in descending order, so that we can easily identify the first 10 rows to figure out our top 10 customers.

This is the first way to create a set. And this particular way is static. So we’re going to basically fix our set. And once we choose our top 10 customers, they’re stuck that way. This has pros and cons. It’s very evident on what you’re doing. And I guess in some ways it’s a pro that you know what’s in that set.

But the con or the drawback is that it’s not dynamic. It’s not going to dynamically update if a new customer enters the top 10. So this way is static. But what you can do is click on the first dimension member on a view. Then go down to the 10th dimension member. I’m going to hold the Shift key while I click on the 10th name.

And that selects the first dimension member, the 10th dimension member, and all dimension members in between. Now if I hover over any of those dimension members, I’ve got some choices. These first two are filters. I can do some sorting, some grouping. But what I’m looking for is this second to last icon that looks like a Venn diagram. That will allow me to create a set.

I will click on that and click Create Set. And these are my top 10 customers by sales, and I’ll call this static. And again, it’s static because those 10 dimension members are basically frozen in there. This list will not change until I open it manually and either exclude names or add names to this set.

Click OK. That was the first way to create a set. You might also notice some slight differences on where these sets show up. As of Tableau version 2020.2, Tableau for the first time in a long time that I can remember, they changed the Authoring interface.

Up to 2020.2, sets had its own area in the Data pane called the Sets area of the Data pane. Now sets are treated more like dimensions. So they’re lumped up there at the top. So if you don’t see your set along with your dimensions, it’s a little bit further down in the Data pane. You likely have not upgraded yet to 2020.2. Previously sets had its own area called the Sets area.

Back to creating a set. That was the first way. That’s static. If you want to create a dynamic set, what you would do is right-click directly on the dimension that you want to create the set from, hover over Create, and click Set. And I will call this my Top 10 Customers by Sales Dynamic.

And to get this to work, what I’m going to do is go over to the Top tab and choose the By Field radio button. And the default is already exactly what I want, but these are changeable. But I’ve already got exactly what I was looking for, top 10 by SUM of Sales.

Just to point out some things you can do, you can change the aggregation. You can change the field. You can change Top to Bottom. And you can change 10 to some other number. But the defaults are actually exactly what I want. So I’ll go ahead and click OK.

And that created another version of the set. The difference is that one will dynamically update as my data refreshes. If a new name enters or drops out of the top 10, that will be represented in the set.

So there’s two different ways to create a set. Now onto some different ways to use these sets. The first thing I can do is drag a set to the Columns or Rows Shelf and use it as a dimension so when I drag that to the Columns Shelf, it created two different columns. The left side are the dimension members that are in the set. The right side are the dimension members that are not in the set.

Sets are Boolean. So you’ll see this every time. And what I mean by Boolean, you typically think of that as true or false. But I think of it more generally as anytime there are exactly two outcomes. In this case, those two outcomes are you’re in the set or you’re out of the set. You can only be one of those two things.

So that is why we see two different columns. We’ll always have two outcomes with sets, In or Out. This particular usage might make a little bit more sense if I bump that set down to the Rows Shelf, because what this version will do is draw a row for the 10 dimension members that are in the set first, and a row for the 783 dimension members that are not in the set second.

Essentially, we just drew a line after our top 10. But point is, the first way to use a set is as a dimension. As you can see, it’s blue telling me it’s discrete. And just like Customer Name is the other discrete dimension that I’m using right now, it’s drawing a row for whether they’re in or out of the set first, and then a row for the particular customer name.

Because these are discrete, I can reorder them. So I could put my in or out of the top 10 after Customer Name. And instead of drawing one block of a row with the top 10, now I’m just seeing the classification in that second column. Whether each individual customer is in or out of the set.

That’s sets as a field. You can also use sets as a filter. If I were to drag that same set onto the Filters Shelf, the default behavior is for Tableau to keep only the dimension members that are in the set. However, you can modify this filter once it is on the view by clicking on it on the Filters Shelf, and there’s a second option.

So again, by default, when you add a set to the Filters Shelf, it’s going to keep only the members that are in the set. But there’s one other option. If I click Show In or Out of the set, first of all, it gives me the choice. I’ll just leave it as In for now, to show you that there’s no change.

But now, if I were to show that filter, the user would have the ability to show the members that are in the set, the members that are outside of the set, or everybody. So now we’re back to all 793 customers in the dataset.

Next I’m going to show you perhaps my favorite way to use a set, which is as a highlighter. For this one, I’m going to throw together a quick scatter plot that looks at Sales and Profit by Customer Name. Put that on Detail. Actually, I’m going to flip these axes.

If scatter plot’s new for you, it’s my third favorite chart type. Just search for scatter plot. We’ve got several videos here at Playfair Data TV to show you how to get the most out of this chart type. All right. Make those circles a little bit bigger. And here’s what I mean by highlighter.

So this is the same 793 customers, but now they’re represented in a different way. Over on the first view, it was simply a bar chart sorted in descending order. Now we’ve got a second variable, so that we can get some more context. This often leads to more insight in the business.

And to help with that insight, I’m going to color these circles by whether or not they’re in the set. And you can do that by simply dragging the set to the Color Marks Card. If they’re in the set, they’ll get one color. Maybe I’ll make that a brighter red. And if they’re out of the set, make it a more neutral color, like a light brown or a gray. Click Apply. Call that good.

That’s a little too dark of a brown. I’ll just change it back to gray. That looked pretty good. OK. So here’s what I mean by a highlighter. And this is how using sets can really lead to some interesting insight. This particular circle is standing out to me. It’s the furthest over on the x-axis for Sales.

But it’s actually below zero in Profit. Let me hover over that and see what’s going on. So that’s Sean Miller. I remember that name from the first tab. He’s actually our top selling customer. So if I looked at that in a vacuum, I might want to figure out how do I make more customers like Sean Miller? This is great. He is by far our leading sales customer.

But if I looked at it through this different lens with– there’s two reasons that– two things that led to this insight. One, I’ve got a second variable, yes, but I’ve also colored it by the top 10 set. So that I can see how Sean Miller is performing in context of all the other customers.

I can see that the other nine members in the set are not only in the top 10 for Sales, but they’re also profitable. In many cases, they’re highly profitable. These top six customers here are not only the furthest to the right for Sales, but the furthest to the top in Profit.

So Sean Miller is way behind. So that immediately gives me an area to focus on or look into what’s going on here. Do we have a typo maybe in the dataset? Is he buying certain products that are not profitable? These are all things that I want to explore, but it was made possible partially by looking at this through the lens of sets.

The next thing I’m going to show you how to do is use sets in a calculated field. For this example, I want to have slightly fewer sets. Or dimension members in the set, rather. So what I’m going to do is start a new sheet. And I’m going to create a set out of let’s go with Sub-Category.

I’m going to right click Sub-Category, hover over Create, and click Set. And I’ll call this my Sub-Category Set. And I’ll throw in the first three. We’re going to alter this later on using set actions, but for now I’ll just– if it starts with the letter A, we’ll put it in the set. And I’ll click OK.

And I’m also going to make a chart that will allow us to QA what I’m going to show you. I’m going to look at SUM of Sales by Sub-Category, and I’ll fit the entire view. OK.

So fourth way to use sets. We’ve done as a field, as a filter, as a highlighter. Now I’m going to show you how to use these in a calculated field. I’m going to create a calculated field. And I’ll call this my Set Calculated Field. And we will say that if– I’ll do SUM as my aggregation. IF Sub-Category Set, then Sales times 2. ELSE Sales. END.

All right. So what this is saying is if you’re in the Sub-Category Set, we’re going to multiply the Sales values times two. This is just one, just basically the first thing that popped in my head, candidly, for a use case. But you can apply this type of logic across any calculated field in your business.

Essentially, it’s going to treat the members in the set differently. This would be much like if– it’s a more elegant way of saying if the sub-category equals Accessories, or sub-category equals Appliances, or sub-category equals Art, then Sales times 2. Else Sales.

But we kind of consolidated that all into a single set. And kind of treat this as an element. If they’re isolated in that set, that set is going to be treated differently than all the other dimension members. Just a lot more easier and it’s more elegant and consolidated by using sets.

Let’s test this out and see if it works by putting my Set Calculated Field on here as a second column. I will also show all my labels, so we can see if this is working. So just kind of eyeballing it, I’m not going to do all the math on these, but it does in fact look like the first three rows have about twice the value, which is exactly what we coded.

Remember, if I edit this Sub-Category Set, there were three things inside of it. This calculated field on the second column is saying, if you’re one of those three dimensions members, take the sales and multiply it by 2. Otherwise, show the original Sales values.

So everything past the first three rows should look exactly the same on the left and the right. And sure enough, it does. So that one’s the fourth way to use a set. It’s as a calculate– within calculated fields.

Now I’m going to show you how to use what’s called a set control. This is a relatively new feature that came with Tableau version 2020.2. So if you have yet to upgrade, you will not see this feature. But this is a really handy way to include or exclude the dimension members that you want within a set.

This acts much like a parameter control, which has been around for a long time. But it’s even more flexible, because you can do a multi select. With parameters, you have to choose one thing at a time. With set controls, you can pick and choose and do a multi select. You can have no dimension members in the set. You can have one dimension member. Or you can have more than one dimension member in the set.

To show a set control, the one catch with this feature is the field, the set, has to be on the view somewhere. In our case, it is on the view because our Sub-Category Set is included within the Set Calculated Field. Because our set is somewhere on the view, I can right-click on the set, and instead of showing the filter– that’s what I already showed you. That’s the one with just two options, either in the set or out of the set –what I can do now is Show the Set.

I click on that. We have that new feature which is called a set control. It looks a lot like a filter, but it is called a set control because you’re controlling which values are included in the set. By the way, if the set that you’re creating is not part of a calculated field and it’s not represented on the view anywhere else, what you could do to solve that is put the set onto the Detail Marks Card. And that would allow you to show the set control from there.

Now that we’ve got the set control, I can add or subtract certain dimension members from it. So let’s keep an eye on– let’s do the first row. So on the left is the original sales value. On the right is the sales value times 2. If I deselect Accessories, we should see the value on the right go back to matching the value on the left. And we do. If I deselect Appliances, it returns to its original value, and if I deselect Art, it returns to its original value.

So again, just a reminder on one of the key differences between set controls and parameter controls. With parameter controls, there’s always a current value of the parameter. So something is always in that field. With set controls, I had the option to go all the way down to nothing in the set control.

So in this case, the left side of the chart looks exactly like the right side of the chart. Now that I’ve deselected the first three, I can also change which values are in the set. Maybe this time I’ll look at the sub-categories that start with a B. If I click Binders and click Bookcases, both of those two rows are the ones that now get doubled their values. That’s called a set control.

The last thing I’ll show you how to do on this video is a kind of older approach. It’s funny to be saying that now, because this is still a relatively new feature. This one came out with version 2018.3. But I’m going to show you how to create a similar user experience that I just did with the set control, using set dashboard actions.

For this one, I’m going to first create a control sheet. So let me give these some names, so that I can find them later on. I’ll call this Sales Versus Sales Times 2. And then I’ll call this my Set Control Sheet.

And for this one, I’m going to put my Sub-Category dimension on the Rows Shelf. And I’m also going to put Sub-Category onto Text. And essentially, I’m just creating a place for my users to click on.

And eventually, this control sheet will allow them– I guess I have to show the header to make those rows a little bit taller. Eventually, this will allow them to click on a Sub-Category dimension member, and have it– have that sub-category added to the set, which will control whether or not it’s being multiplied by 2.

This is going to be kind of a repetitive clunky experience. It’s just for ease of illustration. You could do some really neat things with these control sheets though. For example, you could make these images instead of just the words, because the words will be repetitive to the table that we just built on the last few.

But now that I’ve got my control sheet, and now that I’ve got my Sales Versus Sales Times 2 bar chart, I can create a dashboard. I’ll put my control sheet on the view first. And I’ll put my bar chart on the view second. You can see by default that it carried over the set control as well as the chart.

I’m going to reset this so that we start out with nothing in the set. And this time, instead of controlling the dimension members included in the set by that set control, I’m going to add a dashboard action by going to Dashboard and Actions. Click Add Action. And these are the current types of dashboard actions as of Tableau version 2020.2.

I’m going to click Change Set Values. And I will call this one my Sub-Category Set Action. And this is a relatively intuitive interface. If this is not familiar to you, we do have great video over on the dashboard track that talks about an introduction to Tableau dashboard actions in general.

So I’m going to fly through this. If you need more detail, I suggest you check out that video. But we’re going to say if you click on the Set Control Sheet, so Select is synonymous with click. I want you to go to the Sample Superstore dataset, which is the only dataset in this workbook, and overwrite my Sub-Category Set.

This is kind of the key thing to select. This is the set that we are overwriting with the selections from our Set Control Sheet. You’ve also got a couple of options here. Running the action will assign values to the set, add values or remove values. This is also new as of version 2020.2.

So you might see slightly fewer options. But again, fairly intuitive interface. You might need to do some kind of guess and check of the user experience, just to make sure it’s resulting with exactly what you want. Probably most importantly, other than overwriting the set, is you can tell Tableau what to do when you clear the selection, which you can do by clicking the Escape key.

By default, it will add all values to the set. That’s one of the weird defaults that I’m not a big fan of. I would actually probably revert to removing all values from the set. Because if we automatically added everything to the set, everything would be multiplied by 2.

You can also keep the set values, which would just keep the last selection in place. But most the time, I’m going to remove all values from the set. And we’ll call this set action good for now. I’m going to click OK. Click OK again to close that. We don’t see anything change yet. But now if I click on Accessories, Accessories gets overwritten in our Sub-Category Set. On our bar chart, it’s multiplied by 2.

And just for some visual confirmation that that worked, it also got selected in my newly added set control. You can do a multi select with set actions, but it’s a little bit clunky, and you definitely have to train your end users, because what they have to do is hold the Control key while they click additional dimension members.

So they would hold Control, click a second dimension member, hold Control, click a third, hold Control, click a fourth. And you can see these changes happening in real time. You could do that already as of version 2018.3 using set actions like I just showed.

If you click the Escape key, that clears the selection. And because within our set action, we told Tableau to remove all the values from the set, you saw that now no longer is my control sheet highlighted. But my set control has no values inside of it. To show you this one more time, I’m going to click Chairs, hold Control, click Copiers.

And just to give you one more idea on which is the best choice for you, this is a very friendly user experience. It’s kind of nice to be able to click on stuff and have those dimension members be added to the sets. But the drawback is the UX of having to coach the user on holding Control and how to do a multi select.

With the new set control, it’s a lot more intuitive on what’s happening. When I deselect these, it’s just like most other filters. Those go away. They’re no longer in the set. If I want to do a multi select, I know which boxes I’m checking. So it’s a little bit more of an explicit UX. You kind of know exactly what’s happening.

But it’s also not quite as elegant. We can’t make the selections with buttons or nice custom images. So there’s some pros and cons to both. That choice will be up to you. But this has been an introduction to sets in Tableau.

I’m Ryan with Playfair Data TV – thanks for watching!