How To: Create a Relative Map Using Set Actions with Tableau

11/07/2018 Matt Chambers 1 Comments

One of the greatest analytical abilities that we gain with set actions in Tableau is that we can now create interactions that are relative to other data points.  It's all relative, right?  So how do we do this?  I'm going to walk you through creating a map that shows the profit of other states relative to the state you are hovering on.  Huge shoutout and assist to Corey Jones for the level of detail calculation and make sure you check out his blog for the latest in set actions.

The first thing we need to do is create a set that contains the states for the selection in the map:

Next, we will make a calculation that lets us compare the profit for each state relative to our selection:

We use the level of detail calculation to fix the profit of the selection and then we subtract that value from the other states that are outside of the set.  Here's how it works:

If we hover over California, we can see that the profit is fixed across the entire data set, and then each profit for each state is subtracted to create the relative profit.

I also wanted the states to show labels, but I wanted the state that was selected to be blank since it would be compared to itself.  The following calculation creates the labels:

Now we can build our map:

Finally, we add the set action by clicking Dashboard/Actions/Add Action/Change Set Values and setting the action to update Set State on hover and keep set values when clearing the selection.

That's it!  You should have a working map that is calculating relative profit.  You can use this to build any type of relative calculations using set actions as well.

Feel free to download the workbook and comment with any questions.

1 comment: