KNOWLEDGE BASE

Unable to Conditionally Color Axis Header


Published: 02 Oct 2019
Last Modified Date: 20 Mar 2020

Issue

Unable to color only part of the axis using existing formatting function.

Environment

Tableau Desktop

Resolution

As an possible workaround,  using dual-axis and a calculation field could achieve similar result. Please find the attached sample workbook for more details.(built in 2019.3.0)

Step 1: Create two calculated fields

  1. Select Analysis > Create calculated field
  2. Name the calculated field "Container"
  3. Enter the following formula and click OK
    AVG(0)
  4. Select Analysis > Create calculated field
  5. Name the calculated field "Color2017"
  6. Enter the following formula and click OK
    IF DATEPART('year', [Order Date])=2017 THEN "2017"
    ELSE "other"
    END

Step 2: Build the View

  1. Drag Order Date to Columns and Discount to Rows
  2. Drag Measure Names to Color
  3. Drag the new calculated field [Container] to Rows, next to SUM(Discount)
  4. Right-click Container and select Dual Axis
  5. On the right axis named Container, right-click and select Synchronize Axis
  6. On Columns, right-click Year(Order Date) and select deselect Show Header
  7. In the marks cards, select the Container mark and change the visualisation type to Text

Step 3 - Fix the axis location

  1. In this example, we want to lower the text underneath the Bar Chart, therefore we need to lower the value of the [Container] calculated field to AVG(-10)
  2. Remove Measure names from Color.
  3. Drag the new calculated field [Color2017] to Color.
  4. Drag Order Date to Text.
  5. Edit the color palette of the dates as desired. 
  6. (Optional) Hide unnecessary frame border.

Cause

The ability to customize the formatting text on axis is not currently built into the product. Add your vote to the following Community idea: Improve Uniformity on Edit Axis Menu.

Additional Information

To view the above steps in action, see the video below.
Note: the video has no sound.
Did this article resolve the issue?