KNOWLEDGE BASE

How to label only the data that is the maximum value for each measure on a scatterplot


Published: 23 Nov 2022
Last Modified Date: 24 Nov 2022

Question

How to label only the data that is the maximum value for each measure on a scatterplot.

<Current Behavior>
User-added image

<Desired Behavior>
User-added image

Environment

  • Tableau Desktop

Answer

In the example below, only the data with the max Quantity or Sales value is labeled.

<STEP 1>
-Creating scatterplot-

1. Connect to Sample Superstore.
2. Drag [Sales] to Rows and [Quantity] to Columns.
3. Drag [Sub-Category] to Color on Marks.

<STEP 2>
-Labeling only the data that is the maximum value-

4. Create a new calculated field as following.
     Name : Labeling Max Quantity and Sales
     Calculation : IF SUM([Sales]) = ATTR({FIXED :MAX({FIXED [Sub-Category]:SUM([Sales])})})
                          THEN ATTR([Sub-Category])
                          ELSEIF SUM([Quantity]) = ATTR({FIXED :MAX({FIXED [Sub-Category]:SUM([Quantity])})})
                          THEN ATTR([Sub-Category])
                          END
5. Drag [Labeling Max Quantity and Sales] to Label on Marks.
 
Did this article resolve the issue?