Using calculated fields to enable you to differentiate between data points in labels. Useful if you want to isolate and highlight specific Dimension members, or Measures above or below a certain threshold.

The inspiration

Now that I have finished documenting chart types, I’ve started to download nice looking workbooks so I can try to recreate them. The hope is that if I do this often enough, I can  force some nice design practise into my (limited) repertoire.

In doing this, I’m finding lots of nice little tips where more established users might think “Well I knew that, who doesn’t know about that little trick?”. Well, it’s me – and I’m probably not on my own!

One of the first workbooks I took apart was a #MakeoverMonday submission by Pooja Gandhi. It’s a terrifically well-crafted viz and something that I aim to get vaguely close to in the coming months:!/vizhome/TheNexttoDie-ExecutionsintheU_S_/TheNexttoDie-ExecutionsintheUS

Screen Shot 2016-07-21 at 19.37.09

The tip

There’s a lot to like, but one little detail stood out for me. How has the different colouration on those noose labels been achieved? It’s simple! Download the week 29 dataset from here:

The actual hanging noose is just a dual-axis combination of a bar chart on a reversed scale, plus a shape.

If I roughly create the initial visualisation and add State and Number of Records to the Shape Marks card, I get this:

Screen Shot 2016-07-21 at 19.52.30

The issues are:

  • Placement
  • Colouration
  • Size

In Pooja’s original, the State and number of executions are nicely visible below the noose. Why is mine overlapping, and how do I fix this? Simple. Tableau defaults to fix the range of the axis to the range of the data – there’s no “breathing space”. To resolve that, I just showed the Header and edited the axis as shown here:

Screen Shot 2016-07-21 at 19.55.52

The highest value in the dataset is the 537 executions in Texas. Tableau automatically creates a Fixed End at 656, and that squeezes the space available for the label. Bumping it to 800 creates that space.

What about this issues relating to colouration and size? How has Pooja got Texas to be red whilst all the others remain grey, and why is the font size bigger for Texas? Again, it’s a simple logical solution. All you need to do is differentiate between Texas and the other States, using a couple of basic calculations. Firstly to identify where the State IS Texas, and secondly where it IS NOT Texas:

Screen Shot 2016-07-21 at 20.04.05

Screen Shot 2016-07-21 at 20.04.29

Simple Boolean statements yielding a True or False output. How does this help? Add them to Labels, and they obviously become available within the Edit Label window:

Screen Shot 2016-07-21 at 20.17.15

Then it’s just a case of formatting the label as you want the end product to look:

Screen Shot 2016-07-21 at 20.20.22

So the font size and colour is applied to the calculation. Where “State is Texas” is true, I’ve bumped up the font size and coloured it red. Where “State is not Texas”, I haven’t adjusted size or colour (note that you may need to tick the “Allow labels to overlap other marks” box.

The simple concept is that with Texas having such a high number of executions, encoding it by colour, size AND in conjunction with the chart itself, it really makes this datapoint stand out:

Screen Shot 2016-07-21 at 20.23.23

You can obviously extend the principle further, by applying the colouration to the chart elements too. This is just a case of dragging the “State is Texas” calculation to the Colour section on both Marks cards, and editing the colours accordingly.

Screen Shot 2016-07-21 at 20.26.24

A small tip, but one that I’m keen to remember. Downloading dashboards and recreating little elements like this is a great way to learn, and I’m aiming to document these on a regular basis for the blog.