Last modified date: 20 Jul 2023
Environment
- Tableau Desktop
Answer
The attached example workbook uses the sample data set Superstore to demonstrate the following directions:- Drag [Region] to the Columns shelf
- Drag [Sales] to the Rows shelf
- Drag [Profit] over the axis for Sales and drop the field
- Move [Measure Names] from the Columns shelf to Colour on the Marks card
- Create a calculated field with a name like "All or each segment colour" with a calculation similar to the following:
IF { FIXED : COUNTD([Segment])} = {EXCLUDE [Segment] : COUNTD([Segment])}
THEN "All"
ELSE [Segment]
ENDNote: 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])
- Shift-drag [All or each segment colour] to Colour.
Additional information
It will be necessary to change the [Segment] filter and manually set the colour for that filter selection. And then repeat this process for every possible [Segment] filter selection.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
Related links
Results 1-3 of 778
Trending Articles
Results 1-3 of 778