BASE DE CONNAISSANCES

How to apply color condition to only one measure value


Date de publication : 04 Jul 2023
Date de dernière modification : 07 Jul 2023

Question

How to apply color condition to only one measure value.

In this case, suppose you want to apply the color condition only to Profit and not to Sales.
The color condition should be "Blue" if Profit is greater than or equal to 0, and "Red" if Profit is negative.

<Current Behavior>
User-added image

<Desired Behavior>
User-added image

Environnement

  • Tableau Desktop

Réponse

Please follow along with the attached sample workbook to the right of this text in the Attachments section.

<STEP 1>
-Creating Crosstab-
1. Connect to Sample Superstore from Tableau Desktop.
2. Drag [Order Date] and [Category] to Rows.
User-added image
3. Drag [Region] to Columns.
User-added image
4. Drag [Profit] to Text on Marks.
User-added image
5. Drag [Sales] to crosstab as follows.
User-added image

-Set the Color Condition to Profit-
6. Create a new calculated field as following,
     Name :Profit Color Condition
     Calculation : IF SUM([Profit])>=0
                          THEN "BLUE"
                          ELSE "RED"
                          END
7. Drag [Measure Names] to Color.
User-added image
8. Drag [Profit Color Condition] to Detail.
User-added image
9. Click on Detail mark of [AGG(Profit Color Condition)] -> Select Color.
User-added image
10. Click on Color Legend delta mark -> Edit Colors
User-added image
11.Change the color as follows
​​​​​​     *Profit, BLUE -> Blue
​     *Profit, RED   -> Red
​     *The others   ->  Black
User-added image
 
Cet article vous a-t-il permis de résoudre le problème ?