How to Colour Scale a Map Using Set Actions!

I thought my Best of DS11 blog would be my final blog post on the Data School website but no, I have one quick blog post left. Set Actions. They’re new and exciting, right? Today at the Data School, Harry of DS11 taught us (and the coaches) set actions as he was assigned to teach the public this topic a few weeks ago. He has two blog posts on set actions which will delve much deeper than my blog post right now, check them out here and here. Andrew has also written one on proportional brushing here.

In this blog post, I will show you how to use set actions to change the colour scale of your filled maps depending on the locations you choose to lasso.


Let’s start!

Figure 1 below shows a map of Europe with sum of sales on colour (this is EU Superstore). The first step to creating this set action is to create a set. Right-click on ‘State’ which is every region or some sort of chunk within each country and click Create> Set. Select all the “states” and call the field ‘State Set’.

Fig 1. Starting map



Next, we’ll create a calculated field called ‘Colour Selected States’ and the calculation is as in Figure 2. This calc is saying that when the set is ‘IN’ then return Sales. You don’t need to specify [State Set]=’IN’ or anything like that, writing [State Set] alone will work.

Fig 2. Colour Calc


Instead of SUM(Sales) on Colour, drag your new ‘Colour Selected States’ field on colour. Now, we will set up our set action. In the Worksheet tab at the top of your workbook, click on Actions and add a set action. This is called ‘Change Set Values’ in the actions list. Now configure your set action as shown in Figure 3. So the set action will come into action when you select a number of states, in this case, through lasso-ing. The target set is the set that our calculation that’s in the view is based on, i.e. State Set.

When we deselect the states we’ve lasso-ed, we want the map to reset to show all the states overall, so we will choose ‘Add all values to set’. If we choose ‘Remove all values from set’, then our map will return null values. If we choose ‘Keep set values’, then our map will keep the colour on the states you previously selected all other states will be coloured the null colour. With ‘Add all values to set’, the colour will return to original colour scaling for the entire map when you deselect your states.

Fig 3. How to set up your calc



Ta-da! Colour Scaling!



That’s all, folks!


Louise


Check me out my blog feedmedata and follow me on @FeedMeData_

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s