Conditionally Color View by Each Value or All Values Combined

Published: 24 Sep 2018
Last Modified Date: 18 Sep 2020


How to color marks differently for each dimension member, or another non-segmented color when all dimension members are shown in the view


  • Tableau Desktop


The attached example workbook uses the sample data set Superstore to demonstrate the following directions:
  1. Drag [Region] to the Columns shelf
  2. Drag [Sales] to the Rows shelf
  3. Drag [Profit] over the axis for Sales and drop the field
  4. Move [Measure Names] from the Columns shelf to Color on the Marks card
  5. Create a calculated field with a name like "All or each segment color" with a calculation similar to the following:

    IF { FIXED : COUNTD([Segment])} = {EXCLUDE [Segment] : COUNTD([Segment])}
    THEN "All"
    ELSE [Segment]

    Note: The FIXED expression will always return the total unique count of segments no matter how the view is filtered. The EXCLUDE expression will return the unique count of segments in the view based on how the view is filtered. It is necessary to exclude [Segment] otherwise each mark in the view will return 1 (since each bar segment only has one value of [Segment])

  6. Shift-drag [All or each segment color] to Color.

Additional Information

It will be necessary to change the [Segment] filter and manually set the color for that filter selection. And then repeat this process for every possible [Segment] filter selection.

Discuss this article... Feedback Forum
Did this article resolve the issue?