Often a client will ask for colourful tables to be built in Tableau, where they want some columns to be highlighted and others to be left un-highlighted. Sometimes this could be called conditional formatting in Tableau.
If the requested highlighting is very simple – for example only highlighting Sales by the amount of sales, highlighting Profit by the amount of profit, etc – then to colour measures in different colours is straightforward. More complex business rules are likely to require a different technique, probably using the Placeholder technique.
This article covers the more simple method of conditional formatting within a Tableau table.
Building a Tableau table using the standard Measure Names / Measure Values to enables each measure to have a different colour scheme.
Using sample superstore data, this simple example shows how to colour Profit by profit or loss, without colouring Sales. The State field will be used as the dimension to slice the data.
In your Tableau worksheet create your table using the Measure Names / Measure Values pills. (Small tip – place a single measure in the Text / Label mark then double click another measure in the Measures list; Tableau will automatically convert your view to a Measure Names / Measure Values table!)
Set the Mark type to Square and ensure Measure Values is on both Label and Colour. Both measures show the Tableau default colours.
To reiterate we want highlighting of the Profit but no highlighting of Sales.
Click the small drop down arrow of the Measure Values pill on the Colour shelf and choose “Use Separate Legends”.
The legends for both Sales and Profit should automatically appear, from where you’re able to edit the colours for each. Click the small arrow on the top right of each legend and Edit Colours.
Set the Profit colours as a 2 Step with zero at the centre, this highlights whether there was profit or loss. The Tableau Automatic red / blue colours have been used for this example.
Sales should not have any highlighting. Colouring everything white is a solution, which is more complex than could be expected. (Unless I’m missing something, please add in the comments if there’s a better way.) As Sales is a continuous measure we are forced to colour by a range. Therefore white should be the colour at both the top and bottom ends of the range.
Use a Custom Diverging colour scheme and set both ends of the range to have the white custom colour (HTML = #ffffff), allowing only 2 steps. The 2 steps forces the top and bottom of the range colours to be used.
That provides, in relatively quick time, a basic level of conditional formatting for a Tableau table.