Creating conditionally formatted tables is a regular request for Tableau consultants.
This is very similar to what users are used to in Excel.
For example, they may want some columns to be highlighted and others to be left without highlighting.
Conditional formatting in Tableau is an appropriate description.
For simple highlighting requests – for example only highlighting Sales by the amount of sales, highlighting Profit by the amount of profit, etc – then it is quite straightforward.
Colouring a measure by itself is the simplest way to do conditional formatting in Tableau.
More complex business rules are likely to require a different technique, probably using the Placeholder technique.
For example, to colour Sales by the YoY Change use the Placeholder technique; that isn’t possible using the simple technique detailed below.
This article covers the more simple method of conditional formatting within a Tableau table.
How to do Simple Conditional Formatting in Tableau
Building a Tableau table using the standard Measure Names / Measure Values 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. We use the State field 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.
Adding Colour to the table
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. This example uses the Tableau automatic red / blue colour scheme.
Sales should not have any highlighting. A solution is to colour everything white, however this is more complex than one might expect. (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. Setting to 2 “Stepped Colour” forces using only the top and bottom of the colour range.
The final formatted Tableau table
That provides, in relatively quick time, a basic level of conditional formatting for a Tableau table.