I recently came across the blog post on using Arcade to summarize data in cluster symbology pop-ups using information from aggregated features (https://www.esri.com/arcgis-blog/products/arcgis-online/mapping/summarize-and-explore-point-clusters...). Using the solution in the example that's demonstrating a table of custom attributes (section 4 in the post), I essentially copied and pasted the example Arcade into the Arcade set up in my web map for clusters, and swapped in the relevant field names. I'm getting empty elements in the table at every level... checked four times for typos.
In this dataset, there are a bunch of points representing port surveys of fisherman. The points each have a bunch of info about day and location where they fished, what species they were targeting, and how much they caught and harvested of that target species. I'm trying to get the cluster pop-up to provide harvests and catches by target species of the aggregated features (for use in a dashboard where folks can filter on attributes like port and date). Here's the code I'm working with to try and get a table of Harvest by TargetSpecies from each aggregated cluster:
Expects($aggregatedFeatures, "TargetSpecies", "Harvest")
var attributes = {};
var fieldInfos = [];
var statsFS = GroupBy($aggregatedFeatures,
[
{ name: 'species', expression: 'TargetSpecies'},
],
[ // statistics to return for each unique category
{ name: 'harvest', expression: 'Harvest', statistic: 'SUM' },
// { name: 'num_features', expression: '1', statistic: 'COUNT' }
]
);
var ordered = OrderBy(statsFS, 'harvest DESC');
for(var f in ordered){
var type = f.species;
attributes[type] = Text(f.harvest, "#,### harvested");
Push(fieldInfos, {
fieldName: type
});
}
return {
type: "fields",
title: "Total harvested by species",
attributes: attributes,
fieldInfos: fieldInfos,
}
And the result:
And the view in the pop-up:
Does anyone have thoughts on why this may not be working based on the info I shared?
At first glance not sure you need the "," after line 10, since line 11 is commented out.
I was going back and forth on that comma, too. It's there in the example web map from the blog post where there is only one statistic (example 3) even... but I just removed it again in my expression with your suggestion, and it appears not to make a difference. Darn, thanks for the idea, though!
From the blog post (example 3), for reference:
Dang... now I'm going to have to look at it closer.... I found the sample map viewer project the original code you borrowed from was based on (I don't have good cluster data to test against).
Power Plants around the Globe (arcgis.com)
I then copied your code in a custom clustered popup in that project and just changed the attribute names back to the names from the original code your borrowed from (I.E. your code with just field names changed). And.... it worked :-(.
I would have preferred if it didn't because then I would have something to solve for.
Here's the code I used if it helps. Maybe I changed something small like a comma or capitalization without realizing it. Hope this helps. If nothing else, the fact that it works might provide a clue.
Hey thank you for the troubleshooting support!! So this is really funny... the pop-up completely works as expected in the dashboard, just not in the web map. Maybe a bug?
Here's the dashboard view:
I guess that's really where that counts here. And who knows, could be the weather where I am for the inconsistency over web tools, ha!