In this blog I will teach you how to have multiple set actions on one sheet. After seeing two blogs posted by Alex Stephens and Summer Dong from the Data School AU, I was inspired to combine what I learned from them into one functional sample dashboard. The dashboard above on Tableau Public essential solves a problem you have with Sets where you can only have one set action per sheet.

Download the twbx from Tableau Public to see what how I did it!

A quick lesson on Sets and Set Actions:

  • You can create sets out of Dimensions but not Measures.
  • Once your set is created, you will have the option of making Set Actions on your Worksheet or your Dashboard by going to either Worksheet / Dashboard > Actions > Add Action > Change Set Values.

A quick disclaimer about sets and set actions:

When you configure your set actions, you have the choice of targeting a Data Source and a Set. However, you can only select one data source and only select one set from that data source. This means that you can only change one set at a time. A common set action would be:

  • Run action on: SELECT
  • Running the action will: Add values to set
  • Clearing the selection will: Remove all values from set

The functionality of this would be, if you clicked on a mark or a point on a worksheet, it would add it to a set, and clicking off the mark would remove the value from the set. Now, if you wanted your sets to be more permanent, you could change the setting to ‘Clearing the selection will: Keep set values’. This way, clicking off the mark doesn’t remove the mark from the set.

But then you have a new issue, you have a way of adding values to a set but not removing them. Adding multiple set actions to the same worksheet/dashboard doesn’t really work as expected. Even though you can add a new action to remove a value from a set on select, only one set action will work.

A work-around would be to have two sheets on the same dashboard, one in charge of adding marks to the set, and another in charge of removing marks to the set. And although functionally this works well, aesthetically, it isn’t great. But lets fix that.

Creating the Set

First of all, you’ll need some sort of visualisation that has the points you want to add to the set. In my case its just a grid of squares. Feel free to choose circles instead of squares, I won’t hold it against you.

To create a set, you can right click on a Dimension > Create > Set… (in this case, I created a set with the list of points or the Point ID’s) and call it ‘Squares Set’ (or whatever you want).

Next, add that set to the Color. This way, everything in the set will be one colour, and everything out of the set will be another colour. This is mainly to indicate which squares are in which colour.

Hooray, you have a bunch of points that are coloured based on whether they are in or out of the set.

Sets + Collapsing Sheets

For a more detailed version go see Summers blog here.

A collapsing sheet is essentially a sheet that will disappear when its (apparently) empty. When you’re building your dashboard, you have the option of adding horizontal and vertical containers to it to place your worksheets in. One of the characteristics of sheets in containers is that if there are two sheets in one container and the first sheet were to magically disappear, the second sheet would expand to fill the rest of the container (as long as the titles are hidden and the height/width isn’t fixed).

So how do you make one sheet seemingly disappear?

Lets create a parameter called: ‘Sheet Swapper’.

And using that parameter, create a calculated field called Filter.

Drag that Calculated Field onto the Filter and on Custom Value List type ADD.

Right click on the Sheet Swapper Parameter > Show Parameter.

Change Parameter from ADD to REMOVE. The sheet goes from filled to blank if you change the parameter to REMOVE, but will fill up again when you change it back to ADD.

Now lets do that whole thing again with another sheet. Duplicate the ‘Add’ sheet and rename it to ‘Remove’. Do all the steps above but use the word remove instead.

Next, create a Dashboard. Put a Horizontal Container, and drag in both the ADD and REMOVE sheets into the container. The layout hierarchy should look like this.

TOP TIP: Don’t forget to HIDE THE TITLES or the sheets wont completely swap properly.

Now lets spice it up with some set actions and some buttons.

Multiple Set Actions on ONE Sheet

First off, create a Set Action like this…

Note: In the pic above you can see I have added buttons. These are optional, its really just something that will change the parameter value from ADD to REMOVE and vice-versa. You can easily just use the default drop down menu.

Essentially, what this Set Action does is whenever you click on a square in the ‘Add’ sheet, it will add that square to the ‘Squares Set’.

But now you have no way of removing those squares from that set. So next, add another Set Action like this…

Similarly, whenever the functionality of this Set Action is that whenever you click on a square, it will remove it from the ‘Squares Set’.

Voila, it is done.

How does it work?

Whenever you change the parameter, it will hide or unhide one of the sheets. Since they are in the same container, whenever one has no contents in it (because it has been filtered out) it will shrink in size, and the other sheet will expand to fill its space. Each sheet has one set action attached to it, either an ADD or a REMOVE from set. However, since the sheets are almost exactly the same, you cant really tell when one sheet is swapped out for the other. When you’re adding to the set you’re actually interacting with the ADD sheet, and when you’re removing from the set you’re actually interacting with the REMOVE sheet.

So technically I lied to you, you’re still limited to one set action per sheet but your different sheets swap out with each other.

Additional Note: You’ll also notice that when you click on any of the squares that they dont highlight like they would normally. Thats because I have added a TRUE/FALSE filter/highlight actions to stop that from happening. Read more about it in Alex’s blog.

Kevin Prescilla
Author: Kevin Prescilla

As a late-stage PhD candidate, Kevin’s appreciation for data analytics grew during his studies into poultry nutrition, or as he calls it, “chickens”. It was this appreciation which spurred his decision to change career paths and ultimately led him to apply to the Data School. In his spare time he enjoys powerlifting – ever challenging himself to beat his last max weight - as well as all kinds of gaming, from board to PC. If Kevin could go anywhere in the world, where would it be and why? Well, the answer is Antarctica, as he is fascinated with how people can live and survive down there (although some might argue because it’s the furthest place you can go on Earth from a chicken).