Select to view content in your preferred language

Smart Forms Arcade Calculated Expression - Intersects with Sum or GroupBy

462
0
09-11-2023 10:56 AM
Labels (1)
M_M
by
Occasional Contributor

Hello,

I am trying to write a calculated expression in Smart Forms in AGO Map Viewer.  I have polygons with different owner IDs and would like to have the Total Acres attribute in my form to be calculated when the user clicks on the polygon.  I have this working correctly, however there are multiple non-adjacent polygons that have the same OwnerID.  Is it possible to calculate the Total Acres using Intersects, but summed up for that OwnerID? In the code below, on step 2, instead of returning First, could it return the sum or Total Acres per OwnerID?

I'd like to create a priority list that sorts OwnerID by Total Acres.

// 1. Define the source layer and fields to intersect.
var source_layer = FeatureSetByName($map,"LayerName", ['Acres', 'OwnerID'])

// 2. Intersect the current location with the source layer and get the field value. 
// If there are multiple intersecting features, get the value from the feature that is 
// first returned by the query.
var get_value = First(Intersects($feature, source_layer))

// Step 3. If the current location intersects the source layer, return the value from the source field. 
// Otherwise return null.
if (!IsEmpty(get_value)) {
    return get_value['Acres']}

//GroupedBy expression not used
//var taLayer = GroupBy(get_value, 'OwnerID', { name: 'TAcresPerOwner', expression: 'Acres', statistic: 'SUM' });

 

Thank you!
Melissa

 

0 Kudos
0 Replies