It is very useful to perform color coding in your visualization.
You can show values which are above or below a threshold value in a different color.
In Tableau you can achieve this by using a calculated field.
- Create a visualization according to your requirements
- Create a calculated field on the column you want to color code
- Give a use friendly name to your calculation and enter code similar to the following
- Drop your calculation on the color mark
- Tableau will automatically show color based on your color mark. If you want to change these colors, click on color mark and select edit color and choose a color palette from the drop down.
Colors can be applied to different charts, learn how to create different charts in Tableau
Please watch my video below to learn how to achieve color coding in Tableau
4 thoughts on “Tableau – Color coding”
Thank you, that is helpful when I want to get specific colors. How do I tell Tableau to use those colors by HTML code in my calculated field?
For example if my Calculated Field formula is:
IF AVG(measure) < 39.6 THEN "Grey" Else "Green" END
Where I have "Green" how do I tell Tableau to actually use Green instead of the default based on palette.
Currently I have to edit the color, manually change the colors to Green and Grey, otherwise they default to blue and orange. (And then they revert to blue and orange once I save and reopen).
When you use a calculation like this IF AVG(measure) < 39.6 THEN "Grey" Else "Green" END You are not creating a color but just a measure. You can drop this calculation on the "Color Mark" and click on Edit colors..you should see two default colors Double click on each color and specify the html or rgb code. This will retain consistent colors and will show the same colors when you will open the workbook again. These colors will carry to the other sheets as long as they use the same data connection.
The above steps work great, however when I change the colors to suit my preference, then save the workbook, the color return to the original ones assigned by Tableau when I dropped the calculated field on the color mark. This happens both when I reopen the workbook in Tableau Desktop 9.0 (32-bit) or in Tableau Reader 9.0 (32 bit). Any suggestions on how to save the colors in my preference?
To keep the colors consistent, you can assign RGB or Html codes to your colors.
– click on the Color Mark,
– edit color,
– double click on the specific color
– specify HTML code in the HTML edit box. HTML codes will be like #ff7f0e.
In the same location you can specify RGB colors too.