Tableau use Gantt when Square mark type coming out of cell

//

A standard technique to add colour to a column in Tableau is to use a Square mark type. This is how Tableau itself creates a heatmap, when using Show Me.

However, this can cause unexpected incorrect colouring.

Tableau Square mark type colour spilling out of the cell

When adding colour to a Square mark type in Tableau the colour can spill out of the cell, covering other adjacent cells. I don’t know why this happens.

For example see the dashboard below. Hover over the cells and check the tooltip. There is a difference between the Square and the Gantt mark types. The tooltip of the Square mark type cells doesn’t always show the data of the selected cell.

When using the placeholder technique to build a table it is common to use the Square mark type. For example Tableau Heatmaps are tables using the Square mark type.

A previous article describes building Tableau tables using the placeholder technique and the Square mark type. The article includes a method to resolve the colour overspill; duplicating the dimension.

Using the Gantt technique to colour Tableau tables

Here I will show how to format a table using the Gantt. It is almost identical to using the Square mark type, however there is 1 additional step.

To quickly recap:

  1. Create a Placeholder calculated field with the formula MIN(0)
  2. Put the Placeholder on Columns
  3. Change the mark type to be Square
  4. Place the display measure on the Label shelf. In this example I use Profit.
  5. Place the colour measure on the Colour shelf. Profit was also used here but could be another measure such as YoY change
  6. Increase the Size to the maximum, which should mean the entire cell is filled with the colour

This may cause the colour to spill out from the cell. Using the Gantt mark type is one way to rectify that. (An alternative “dimension duplication” technique was covered in the article about building Tableau tables.)

Using the Gantt mark type is almost the same as above but with a few small changes. Firstly #3 will change to a Gantt mark type.

Number 6 will also change; use a calculated field on the Size shelf instead of manually adjusting the width. Create a new calculated field with the formula MIN(1). This field will always return a value of 1. To finish place this new field on the Size shelf.

Hover over the cells and check the tooltips. With the gantt mark type there should be no overspill.

The below image shows the Gantt mark type placeholder; the highlighted bars against the placeholder how the mark type. The additional dual-axis placeholder fields are there for formatting purposes.

comparing the cell colour with a gantt and square mark type
See the colour of District of Columbia with Square vs Gantt

Download the workbook comparing Square and Gantt mark types from Tableau Public to see how it is all put together.

Leave a Comment