KNOWLEDGE BASE

Conditionally Colour Text Marks


Published: 04 Apr 2014
Last modified date: 20 Jul 2023

Question

How to conditionally colour the text marks in a crosstab, text table or view.

Environment

Tableau Desktop

Answer

CLICK TO EXPAND SOLUTION

Option 1: Colour each number as over/under a threshold

To view the steps shown in the below video, please expand the above section.
Note: the video has no sound.
CLICK TO EXPAND SOLUTION

Option 2: Colour each number based on its own value

CLICK TO EXPAND SOLUTION

Option 3: Colour number values based on other discrete fields

To view the steps showed in the below video, please expand the above section. Note: the video has no sound.
CLICK TO EXPAND SOLUTION

Option 4: Colour each column separately

To view the steps showed in the below video, please expand the above section. Note: the video has no sound.

Additional information

Options 1-3 can only colour measure values. Option 4 can colour both measure and dimension values.

By design, Tableau Desktop does not apply colour to dimensions. Restricting colour to measures is one way to focus the viewer on the data in the view rather than on the headers. Therefore to colour dimensions in a crosstab, we must place the dimension values in "container" calculated measures.

Colour can be applied either to the text or background of row/column field labels (aka row/column headers) via the formatting options Format Fields and Field Labels. Currently the ability to apply a conditional colour to field labels is not currently built into the product

Notes on Option 3
  • [Measure Names] cannot be used in a calculated field, which is why it is necessary to add [Measure Names] to Colour as well as the calculated field to determine colour
  • When multiple discrete fields are added to colour on the Marks card, then Tableau Desktop will automatically nest the colours. The first discrete field on Colour is assigned a different colour (blue, orange, green, etc.) and then every value for the next discrete field is given a different shade of those colours. If colours are changed, you can always get back to this default by hitting "Reset" in the Edit Colours dialog.
  • The colour legend created may not be very readable. In this case, consider creating a colour legend as in Creating Legends that Apply to Multiple Sheets
Notes on Option 4:
  • It is not necessary to create multiple "Col" fields, but makes it easier to tell the multiple Marks cards apart because Marks cards are named based on the name of the field.
  • To quickly open a particular Marks card, click on the green measure on the Columns shelf, or click on the axis header in the view.
  • All measure columns must be the same width.
Did this article resolve the issue?