KNOWLEDGE BASE

Creating Conditional Labels


Published: 09 Mar 2017
Last Modified Date: 24 May 2017

Question

How to display labels based on the certain values of fields.

Environment

Tableau Desktop

Answer

Using calculated fields, you can create conditional data labels based on a custom field that includes only the values of interest. This article shows how to create a conditional label that appears on a mark only when a region’s sales for a day are greater than $60,000.

Step 1: Create a calculated field

  • Select Analysis > Create Calculated Field.
  • In the Calculated Field dialog box:
    • Name the calculated field. In the example workbook, the calculated field is named "Outlier".
    • In the formula field, create a calculated field similar to the following:
      IF SUM([Sales])> 60000 THEN 
      SUM([Sales]) 
      ELSE null END
  • Click OK.

Step 2: Build the view

  1. From the Measures pane, drag Sales to the Rows shelf.
  2. From the Dimensions pane, drag Order Date to the Columns shelf, and then drag Region to Columns.
  3. Right-click Order Date and select Month (as a discrete field).
  4. Drag the new calculated field Outliers to the Labels mark card. 
Note: You can show or hide the labels for individual marks. To hide a specific data label, right-click the mark and select Mark Label > Never Show.

Additional Information

To view these steps in action see the video below. 
Note: the video has no sound. 
Did this article resolve the issue?