How to Make Label Colours Dynamic in Tableau
Follow this step-by-step guide to colouring data labels based on their values.
If you'd like to create a chart where the labels change colour depending on the their value, similar to the chart below - just follow these easy steps!
This works by splitting the data series in two using calculated fields:
- null null null null null null 20 120 220 320 420 520
- -580 -480 -380 -280 -180 -80 null null null null null null
When these are combined in a label, the null values aren't displayed and you end up with labels like in the chart above.
💡 Top Tip:
You can use the same method to include more than two colours to your labels. Just create more calculated fields.
Click here for the Tableau workbook
1Create two calculated fields
One for positive values and one for negative values:
You can customize this for your specific chart by changing the condition in the calculated fields. For example if you wanted to colour all values above 50% then you could use a condition such as IF [percentage] > 0.5 THEN [percentage] END
2Add the calculated fields to the label
3Edit the label formatting
You should now have something that looks like this:
Don’t worry if you see whitespace under the negative values, we’ll fix this next.
Click on the Label square to open the Edit Label box:
Removing this line break will remove the whitespace under the negative values:
Now format the positive and negative values as needed - for example, make the positive values blue and the negative values red:
And there you have it, a chart with labels formatted based their values: