Loading

How to Display Record Counts for Each Item in a Color Legend

Date de publication: Oct 19, 2026
Description

How to display the number of records corresponding to each item in the color legend (e.g., "Blue : Positive 14 records").

Résolution

Follow these steps to create the necessary calculated fields and configure the view.

  1. Create a base color determination field that returns a string based on categories or conditions. For example, name the field [Color Category] and enter the following calculation:
     IF SUM([Profit])>=0 THEN "Blue : Positive" ELSE "Red : Negative" END
  2. Create a calculated field for each category that returns 1 only if the condition is met.

    • For the positive count, create [Positive Count]:
      IF [Color Category]="Blue : Positive" THEN 1 END
    • For the negative count, create [Negative Count]:
      IF [Color Category]="Red : Negative" THEN 1 END
  3. Create a string concatenation field for the legend display. For example, name the field [Legend with Count]. Use the WINDOW_SUM function to sum the number of records across the view and concatenate it as a string.
    IF SUM([Profit])>=0 THEN

    [Color Category] + " " + STR(WINDOW_SUM([Positive Count])) + " records"

    ELSE

    [Color Category] + " " + STR(WINDOW_SUM([Negative Count])) + " records"

    END
  4. Drag the [Legend with Count] field to Color on the Marks card.
  5. Right-click the field, select Compute Using, and specify the appropriate dimension, such as Table (across) or Table (down).
 
Ressources supplémentaires

WINDOW_SUM is a table calculation function. The correct count may not be displayed immediately after placing it on the Marks card, but configuring the direction correctly using Compute Using will display the expected overall count.

For more information, see WINDOW_SUM.

 

Numéro d’article de la base de connaissances

005461752

Pièces jointes

sample.twbx

1154 KB

 
Chargement
Salesforce Help | Article