Creating Conditional Labels

Published: 09 Mar 2017
Last Modified Date: 08 Jan 2019


How to display labels based on the certain values of fields or through a parameter selection


Tableau Desktop


Option 1 - Based on field values

Using calculated fields, you can create conditional data labels based on a custom field that includes only the values of interest. This step 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 
      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. 

Option 2 - Based on a parameter selection

The following solution uses Segment from the Superstore data set. Replace all instances of Segment with your dimension field.

  1. Create a new parameter - this example names it 'Choose Segment'.
  2. Leave it as a string and from the Add from Field option choose the dimension that will show a single label.
  3. From the Analysis menu, choose Create Calculated Field and type a formula similar to the following:
    IF [Segment] = [Choose Segment] THEN [Segment] ELSE '' END
  4. Drag the original Dimension (Segment) onto the Columns shelf
  5. Drag the new calculated field right after it onto the Columns shelf.
  6. Right click and hide the first dimension by deselecting Show Header.
  7. Show the parameter and select the label that should be shown.
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 the steps in Option 1 in action see the video below. 
Note: the video has no sound. 

Discuss this article... Feedback Forum
Did this article resolve the issue?