I'm struggling to create an expression to sum the total area of a project for a certain attribute. The areas are continuous so I'd like to be able to create a label that had both the features acres and total acres

The data structure is currently: ProjectName, Type, Acreage

The Type is one of two things:

  • Useable
  • Unusable

Screen shot of data

Acreage is labelling expression to convert sq m into acres.

Is there a way that I could get the label to return the Sum of all Useable and Unusable depending on the project?

The desired label would look like:

Project - xxx
Type - Usable rent
Acres - xxx

Total Acres of Usable Rent for Project: xxx
Total Acres of Unusable Rent for Project: xxx

  • Apologies that was unclear. I would like two figures on the label. One figure for total useable land and one for unusable land within a project.
    – MoeS
    Commented Mar 24, 2022 at 16:30

1 Answer 1


I don't believe what you want is possible when creating a label as the functions that allow you to access and summarize data from an entire layer do not appear to be available when labelling. It seems you are limited to $feature, but you can create the text as a pop-up.

To answer your question I have to spoof up some sample data, this is shown below:

Sample data

You then configure the pop-up and create an expression:

// Get the project, type and acres for feature
var p = $feature["Project"];
var t = $feature["Type"];
var a = $feature["Acres"];

// Create a SQL query to query at a project level for the feature
var q = "Project = '" + p + "'";

// Compute sum area for project/type, this creates a featureset
var fs_stats = GroupBy($layer,['Project','Type'],{name: 'TotalArea', expression: 'Acres', statistic: 'SUM'});

//Create subsets from fs_stats
var fs_Proj = Filter(fs_stats,q); //Creates featureset for just project
var fs_Unused = Filter(fs_Proj,"Type = 'Unuse'"); // A featureset of 1 row
var fs_Used = Filter(fs_Proj,"Type = 'Use'"); // A featureset of 1 row

// Extract out the Total area for the unused type for the project
var TA_Unused = 0;
for(var f in fs_Unused){
 TA_Unused += f["TotalArea"];}

// Extract out the Total area for the used type for the project 
var TA_used = 0;
for(var f in fs_Used){
 TA_used += f["TotalArea"];}

// Create text for pop up
var l = Concatenate(["Project - " , p , TextFormatting.NewLine , "Type - " , t , TextFormatting.NewLine , "Acres - " , a, TextFormatting.NewLine, "Total Acres of Usable Rent for Project:", TA_used,TextFormatting.NewLine,"Total Acres of Unusable Rent for Project: " , TA_Unused]); 

// Return text that becomes the pop-up text
return l

I then assigned this expression to the Title and turned off fields

The final output is:


  • Thanks this is really helpful. I do have a new issue with this expression. The 'Acres' field is static and needs to be updated using field calculator. I have another 'pop up' that calculates the acres using the expression: AreaGeodetic($feature,'square-meters')*0.000247105 Is there a way to use this figure as the expression? Instead of 'Acres' it would be this?
    – MoeS
    Commented Oct 7, 2022 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.