Last Modified Date: 20 Jul 2023
Environment
Tableau DesktopAnswer
CLICK TO EXPAND SOLUTION
Option 1: Color each number as over/under a threshold
This method uses a divergent color palette to color text based on whether it is over or under a threshold.
These directions assume the view is already built. For an example with directions from scratch, see the "Opt 1: Divergent Color Palette" worksheet in the workbook in the right-hand pane of this article.
Example 1: Create calculated fields for each measure used
- Drag the desired measure to Color on the Marks card. Note: if the view has multiple measures, then drag [Measure Names] onto Color.
- Click Color on the Marks card and click Edit Colors....
- In the Edit Color dialog, do the following and click OK
- For Palette, pick a diverging color palette
- Check Stepped Color and choose 2 steps
- Optional: Click Advanced >> and/or check Center and type in the desired threshold value
Note: the video has no sound.
CLICK TO EXPAND SOLUTION
Option 2: Color each number based on its own value
Separate color legends is a feature added in Tableau Desktop 10.2 that allows each measure in a view to be colored by a continuous scale based on its own value.
These directions assume the view is already built. For an example with directions from scratch, see the "Opt 2: Separate Legends per Measure" worksheet in the workbook in the right-hand pane of this article.
- Drag [Measure Values] from the data pane onto Color on the Marks card
- On the Marks card there will be two green [Measure Values] fields, one with the "T" icon for Text and the other with the four colored dots icon for Color. Right-click the [Measure Values] with the Color icon and select Use Separate Legends
- Right-click the color legend for the first measure (on the legend itself, not the title) and select Edit Colors…
- In the Edit colors dialog, select the desired color palette and options
- Repeat steps 3-4 for every measure
- Right-click the color legend for a measure, and select Edit Colors…
- In the Edit colors dialog, do the following and click OK:
- For Palette, select Custom Diverging
- Check Stepped Color, and select 2 Steps
- Click the starting color box
- In the Select Color dialog that appears, for HTML type in #333131
- Repeats steps c & d for the ending color box
- Click the down carrot in the top right-hand corner of the SUM(Sales) legend, and select Hide Card
CLICK TO EXPAND SOLUTION
Option 3: Color number values based on other discrete fields
Multiple discrete fields can be added to Color on the Marks card, and then each combination of values can be colored differently. This method has a lot of flexibility as it can allow each measure to be colored by a different calculated field.
These directions assume the view is already built with a calculated field that determines color called [Color KPI]. For an example with directions from scratch, see the "Opt 3: Multiple Discrete Fields on Color" worksheet in the workbook in the right-hand pane of this article
These directions assume the view is already built with a calculated field that determines color called [Color KPI]. For an example with directions from scratch, see the "Opt 3: Multiple Discrete Fields on Color" worksheet in the workbook in the right-hand pane of this article
- Drag [Color KPI] onto Color on the Marks card
- Drag [Measure Names] from the data pane to Detail on the Marks card
- Click the Detail icon next to the [Measure Names] field on the Marks card and select Color
- Click Color on the Marks card and select Edit Colors…
- In the Edit Colors dialog, select the desired color for each combination of discrete field values
CLICK TO EXPAND SOLUTION
Option 4: Color each column separately
This method has the most flexibility, but is also the most complicated to set up. This is the only option that will allow dimension values to be conditionally colored. These directions are demonstrated in "Opt 4: variation (only measures)" worksheet in the workbook in the right-hand pane of this article.
Step 1: Create calculated fields for each measure used
- For every measure that you want to include in the view, select Analysis > Create Calculated Field.
- Name the field. Consider including the name of the measure in it. For example, Sales Col.
- In the Formula field, type 0, and then click OK.
Step 2: Build the view
- Drag Region and Order Date to Rows.
- Drag Segment to Columns.
- Drag each calculated field that you have created to Columns.
- In the ALL Mark cards, ensure the Text is selected as a Mark Type.
- In each mark card, drag the associated measure to Text and to Color. For example, drag Sales to Text in the SUM(Sales Col) mark card.
- Modify the color of each measure as desired.
- Right-click each measure on the axis and select Edit Axis
- Navigate to the Tick Marks tab > select None for Major tick marks and Minor tick marks, and then click OK.
- In the Rows, right-click any of the calculated field and select Format.
- Click the Lines icon and navigate to the Columns tab.
- In the Zero Lines drop-down menu, select None.
- In the Grid Lines drop-down menu, select None.
Step 3: (Optional): move titles to the top
- For each desired column in the finished crosstab, drag two copies of the calculated fields created in the directions above to Columns.
- Drag the desired measure to Text in both copies of the calculated field.
- Right-click on the second copy of the calculated field on the Columns shelf and select Dual Axis.
- Edit both the top and bottom axes as desired.
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
- 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.
Thank you for providing your feedback on the effectiveness of the article.
Open new Case
Continue Searching
Knowledge Base
Community
Product Help
Training and Tutorials