KNOWLEDGE BASE

Creating Tooltip Fields that do not Show for Null or Zero Values


Published: 04 Feb 2015
Last Modified Date: 20 Jul 2023

Question

How to hide tooltip fields with 0 or null values.

Environment

Tableau Desktop

Answer

Step 1: Create a Calculated Field to use as our tooltip field

  1. Select Analysis > Create Calculated Field
  2. In the Create Calculated Field dialog box, do the following and click OK:
  • Name the field.  In the example, this field is called "Custom Tooltip for <field name>"
  • Create a calculation similar to the following: 
    IF ZN(AGG()) = 0
    THEN ""
    ELSE "" + STR(AGG()) + CHAR(10)
    END
    
  • An example might look like the following formula when using the Sample - Superstore datasource:
    IF ZN(SUM([Sales])) = 0
    THEN ""
    ELSE "Sales: " + STR(SUM([Sales])) + CHAR(10)
    END
    
  • This logic first converts all null values to zero, and if the value is equal to zero returns an empty string, otherwise it returns a string value of our tooltip. 
  • Be sure to match the aggregation to what was used in the view. 
  • Char(10) is a new line and this will make sense in our next step in order to streamline the tooltip as much as possible.  Note: if this is the end of the tooltip the Char(10) is not necessary.

Step 2: Format our Tooltip for desired behavior.

  1. Drag our newly created calculated field onto the tooltip portion of the marks card.
  2. Edit our tooltip so that the formatting puts all our custom tooltip calculated fields in one line.  For example:

<AGG(Custom Tooltip for some field)><AGG(Custom Tooltip for another field)>

The end result should look streamlined with nothing appearing for values that are null or zero.

Did this article resolve the issue?