KNOWLEDGE BASE

Conditionally Color Text Marks


Published: 04 Apr 2014
Last Modified Date: 20 Jul 2023

Question

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

Environment

Tableau Desktop

Answer

CLICK TO EXPAND SOLUTION

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

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 2: Color each number based on its own value

CLICK TO EXPAND SOLUTION

Option 3: Color 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: Color 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 color measure values. Option 4 can color both measure and dimension values.

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

Color 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 color 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 Color as well as the calculated field to determine color
  • When multiple discrete fields are added to color on the Marks card, then Tableau Desktop will automatically nest the colors. The first discrete field on Color is assigned a different color (blue, orange, green, etc…) and then every value for the next discrete field is given a different shade of those colors. If colors are changed, you can always get back to this default by hitting "Reset" in the Edit Colors dialog.
  • The color legend created may not be very readable. In this case, consider creating a color 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?