KNOWLEDGE BASE

Change the Color of the Numbers on the Tooltip Above and Below a Target Value


Published: 03 Apr 2023
Last Modified Date: 04 Apr 2023

Question

How to change the color of the numbers on the tooltip above and below a selected value.

For example, a pre-selected target value is set as 550,000.  The left image shows the tooltip with a value below the target value in red, while the right image is above the target value and is displayed in black.

User-added image

Environment

  • Tableau Desktop

Answer

In the attached workbook and with the steps below we will be creating a parameter to select the target value.  Then, calculated fields are used for setting the above and below values from the target value.  With this completed, the Tooltip display will be edited to use the calculations.

STEP 1

Creating a bar chart and setting the parameter for a target value.

1. Connect to the Sample Superstore data from Tableau Desktop.
2. Drag Order Date to Columns and Sales to Rows.
3. Change the Mark type to Bar.
User-added image
4. Create a new parameter called Enter Value as demonstrated below and select the target value:
User-added image

STEP 2

Create calculated fields for finding the above and below values from the target value.

5. Create a new calculated field with the following:
     Name : Sales (Above Standard Value)
     Calculation : IF SUM([Sales]) - [Enter Value] >= 0
                                THEN SUM([Sales])
                          ELSEIF SUM([Sales]) > 0 AND ISNULL(SUM([Sales]))
                                THEN SUM([Sales])
                          END
6. Create a new calculated field with the following:
     Name : Sales (Below Standard Value)
     Calculation : IF SUM([Sales]) - [Enter Value] < 0
                                THEN SUM([Sales])
                          ELSEIF SUM([Sales]) > 0 AND ISNULL(SUM([Sales]))
                                THEN 0
                          END

Step 3

Set the tooltip display.

7. Drag Sales (Above Standard Value) and Sales (Below Standard Value) to the Tooltip on Marks.
User-added image
8. Click on Tooltip on Marks and  Add Sales (Above Standard Value) and Sales (Below Standard Value) next to Sales from the Insert Menu.
User-added image
9. Highlight Sales (Below Standard Value) and open the color drop-down to select red and select B for bold. 
User-added image
10. Highlight Sales (Above Standard Value) then open the color drop-down to choose the color black and select B for bold.
User-added image
11. Right-click on the parameter Enter Value and select Show Parameter.
 
Did this article resolve the issue?