Today at work a Tableau challenge came up that I couldn’t overcome alone, but fortunately our Tableau support from The Information Lab means that we have access to a whole bunch of experts who deal incredibly quickly with random requests. Emma Whyte rode to the rescue in this instance.

Here’s the scenario:

  1. Treemap
  2. One colour to always identify a specific dimension member
  3. Sequential colouring on all other dimension members

Here’s how to do it. The first view is simply Sample – Superstore data, having used Show Me to create the Treemap when Sub-Category and Sales were selected:

Screen Shot 2017-03-08 at 19.22.28.png

Let’s say I always want Phones to be highlighted in red, and then the sequential blue colouring can be applied to all of the other Sub-Categories. How do you do that? First, you need a basic boolean to isolate Phones:

Screen Shot 2017-03-08 at 19.25.08

If you stick that directly onto Colour, it is handled as a Dimension and it also clears SUM(Sales) from Colour. As a Dimension, it is isolated as its own entity, rather than having a dependency on other dimension members. See how it is on its own on the right, and there’s a notable white gap between it and the other Sub-Categories?

Screen Shot 2017-03-08 at 19.25.54.png

To resolve this and reintroduce it to its Sub-Category friends, you just right-click it on the Colour card and convert it to an Attribute. I found the standard Tableau knowledge base article to define ATTR() best:

When the ATTR function is used, the field becomes dependent on the level of aggregation of another dimension. The field no longer exists as independent values and is now wrapped in an aggregation, and then turned into a measure.

Below you can see the effect of that dependency on the wider Dimension.

Screen Shot 2017-03-08 at 19.28.54

Good. One part done. How do we reintroduce that sequential colour scheme for the other Dimension members? Drag Sales to Detail***:

Screen Shot 2017-03-08 at 19.32.30.png

Now right-click it, and set it to Discrete. Why? Well if it’s Continuous and put on Colour, it will replace ATTR(Phones). If you set it to a Dimension, everything gets disaggregated and all sorts happens:

Screen Shot 2017-03-08 at 19.55.29.png

Final option is Discrete, and you can then convert the Mark type to Colour by using the little icon to the left of the field:

Screen Shot 2017-03-08 at 19.56.34

With that done, you more or less achieve the desired result:

Screen Shot 2017-03-08 at 19.58.08.png

Personally, I consider that graduated colour scale to be the wrong way round – I’d rather the higher value sales were shaded darker. That’s easy to fix – just shove a ‘-‘ in front of the SUM(Sales) calculation at the part marked with three red asterisks (***) above:

Screen Shot 2017-03-08 at 20.05.02

A sample of this technique can be downloaded here.


Emma Whyte set a #WorkoutWednesday challenge based on our Information Lab call. As usual, this resulted in people demonstrating more than one way to overcome an obstacle in Tableau, so here is an alternative way that Andy Kriebel approached the challenge. His blog and workbook can be found here.

Screen Shot 2017-03-22 at 19.22.29.png

The #WorkoutWednesday challenge this week included a more difficult element than the problem we faced at work, in that it contained a parameter to allow users to select the Sub-Category to highlight – whereas at work we always wanted a specific dimension member to be highlighted. Parameters are basis things so I won’t focus on that, but here’s the Colour calculation:

Screen Shot 2017-03-22 at 19.24.49.png

It makes sense and is effective, but doesn’t quite match the brief as the depth of that orange varies depending on the Sub-Category selected.