What we want to do
I recently had the chance to get quite colourful for a dashboard that we are developing at Operation Fistula. The landing page gives the user an overview of the issue areas different entrepreneurs work in, and where in the world they are active. An action filter connects the two sheets so that we can filter the map to just one issue area.


How to do it
We need to create a calculation to get our action filter to behave this way. What we are telling Tableau is basically: When just one of the issue areas is selected, then return just the one value associated with that filter, when there is more than one issue area selected, show the default black
In a calculation it looks like this:
![A screenshot of the following calculation in Tableau, called 'Issue area colours': IF ({exclude [Country] : COUNTD(Issue area and group])}) > 1 THEN 'All' else ([Issue area and group]) END](http://naledi.co.uk/wp-content/uploads/2018/12/2018-09-18_14-24-21.png)
Let’s take that apart.
1. We are creating an IF statement, that tests a condition and returns one of two values: the string ‘All’ or the string that corresponds to the the issue area.
2. When there is more than one issue area, we want to return the value ‘All’ (This could be any other string). The view is broken down to the country level, and each country has a different number of issue areas associated with it. So we need to use a level of detail calculation to exclude the [Country] field from this part of the calculation or ‘All’ might apply to those countries that have only one issue area associated with them. By excluding [Country] Tableau now looks at all of the issue areas in the view and counts each unique issue area once. At the outset this is 23, as this is the total number of issue areas we have in the data.
3. When we apply the action filter (see below for setup details), the whole view will only show one issue area. This is when the first condition of the IF statement is no longer TRUE and the ELSE condition gets activated. Now that we only have one issue area, the calculated field will return the [Issue area and group] field.
So much for the calculation. The next steps are needed to complete the dashboard action setup.
1. Place the newly created calculation on the colour area of the marks card on the map sheet.
2. Place both your sheets onto a dashboard.
3. Set up your action filter so that when you select a bar the map is filtered to just the category that you have selected.
Now, you should see that the map colour has changed, but it will probably not be the same as the colour of the bar that you selected. That is because the colour assignment is tied to a specific field, and while you are referencing the original field [Issue area and group] in your calculation, it is still a new field.
So you need to go through and assign the same colours to the new field as well. This is a bit tricky, as you need to have the action filter activated and need to have the reference colour available to know what you are setting it to. There might be better ways of doing this (and if you can think of one please let me know), but I went with the following steps:
1. On the dashboard, reveal the colour legend for the map.
2. Select your first bar to activate the filter, the colour legend will change to your selection.
3. Double-click the legend, then double-click the dimension member and use the colour picker to get the right colour from your bar.
4. Repeat for every filter selection.
5. Delete the colour legend from your dashboard.
Normally you wouldn’t be using as many colours as I am hopefully, so this should be a fairly efficient process. Caveat is of course that if a new dimension member is added to your data you will need to adapt the colour match manually.