Loading

How to color the text only when specific data is selected in the filter

Publiceringsdatum: Apr 8, 2026
Uppgift
How to color the text when only specific data is selected in the filter.

<Example>
In this case, there is a view showing Sales data by Category.
Only when 'Furniture' is selected in the Category filter, the text color of the value will be 'red' (Image 1)
otherwise it will be 'black'. (Image 2)

(Image 1)
User-added image
(Image 2)
User-added image
Steg
1. Connect to Sample Superstore from Tableau Desktop.
2. Drag [Category] to Rows.
3. Drag [Sales] to Text on Marks.
User-added image
4. Drag [Category] to Filter pane.
5. Right click on [Category] on Filter pane -> Show Filter
6. Crate a new parameter as following -> Right click on parameter [Select Category] -> Show Parameter 
User-added image
7. Create a new calculated field as following.
     Name : Color the text
     Calculation :IF ATTR([Category]) = ATTR([Select Category])
                          AND
                          WINDOW_SUM(COUNTD([Category])) = 1
                          THEN TRUE
                          ELSE FALSE
                          END
8. Drag [Color the text] to Color on Marks
User-added image
9. Right click on [Color the text] on Marks -> Edit Table Calculation -> Set as following.
User-added image
10. Click on Color on Marks -> Edit Colors -> Double click on the color to the left of 'False' -> Select black.
User-added image
11. Check in only 'Furniture' in Category Filter.
User-added image
12.  Click on Color on Marks -> Edit Colors -> Double click on the color to the left of 'True' -> Select Red.
Knowledge-artikelnummer

001470683

Bilagor

Book1.twbx

1200 KB

 
Laddar
Salesforce Help | Article