I have a layer of locations with a related table that contains 'calls for service' to a given location by police, fire, or code enforcement staff. I want to include in the pop up a breakdown of the types of alls made to each location, including the number of each unique type and a summary of a points score applied to each call based on the severity of the call type (for instance homicides get a 10, wiring infractions a 1). I think I can do this using a combination of the GroupBy function and FeatureSetByRelationshipName function. However, I keep running into a problem with the GroupBy syntax where Arcade flags the GroupBy statement and says it is an invalid variable assignment. I've modeled this after examples provided and can't figure out what i am missing in my code which is below. Any thoughts?
var CallsByType = GroupBy(FeatureSetByRelationshipName($feature, "AdaptLocationCallDetails"),
[
{name:'Department', expression:'BU_SOURCE'}
{name:'Type' , expression:'CALLDESCRIPTION'}
],
[
{name:'Total',expression:'1',statistic:'COUNT'}
{name:'Points',expression:'POINTVALUE',statistic:'SUM'}
]
);
Solved! Go to Solution.
The first thing that catches my eye is that you don't have commas separating the objects in the arrays. Also if this is the only line of your expression, make sure to return CallsByType (or don't even declare the variable).
var CallsByType = GroupBy(FeatureSetByRelationshipName($feature, "AdaptLocationCallDetails"),
[
{name:'Department', expression:'BU_SOURCE'},
{name:'Type' , expression:'CALLDESCRIPTION'}
],
[
{name:'Total',expression:'1',statistic:'COUNT'},
{name:'Points',expression:'POINTVALUE',statistic:'SUM'}
]
);
The first thing that catches my eye is that you don't have commas separating the objects in the arrays. Also if this is the only line of your expression, make sure to return CallsByType (or don't even declare the variable).
var CallsByType = GroupBy(FeatureSetByRelationshipName($feature, "AdaptLocationCallDetails"),
[
{name:'Department', expression:'BU_SOURCE'},
{name:'Type' , expression:'CALLDESCRIPTION'}
],
[
{name:'Total',expression:'1',statistic:'COUNT'},
{name:'Points',expression:'POINTVALUE',statistic:'SUM'}
]
);