See all tips |
View as pdf
Conditional Data Labels
| You may have already figured out that you can place a field on the Text shelf to add data labels based on the values of that field. However, often you'll find that you don't actually want to label every mark; rather you may want to label only the outliers, or only the data within your region. Using Tableau's calculated fields you can create conditional data labels based on a custom field that only includes the values of interest. | |||||
Here's how it works.Say you are analyzing the daily regional sales for a supermarket and you want to label all regions that have sales greater than $130,000. Dragging the Sales Total field to the text shelf, adds data labels based on the total sales for each region. |
|||||
|
|||||
To add conditional data labels:1. Select Create Calculated Field on the Measures Data window menu. |
|||||
|
|||||
| 2. In the Calculated Field dialog box, name the field "Outliers" and write a conditional formula that describes the marks you want to label. For example, the formula to only label regions whose sales is greater than $130,000 looks like this: | |||||
|
|||||
| The Calculated Field dialog box should look something like this: | |||||
|
|||||
| 3. Place the new field on the Text shelf. | |||||
|
|||||
| The final view only includes data labels for the regions whose sales are greater than $130,000. | |||||
|
|||||
| Note: If you are using Tableau v3.0 or later, you can show and hide the data labels for individual marks. To hide a specific data label, right-click a mark and select Data Labels > Off. | |||||
|
|||||
|
|||||


![IF SUM([Sales Total])>120000 THEN SUM([Sales Total]) ELSE null END](/files/08_03.gif)



