Howdy!
I have a feature layer that has a field 'site'. For any one site, there are multiple surveys. For example, Houston, Detroit, Pittsburgh PA. Houston has 10 surveys, Detroit 17, Pittsburgh 13.
I'm trying to add a list of the sites (this itself works ok) along with the survey count for the site (not working). E.g.
Houston - 10
Detroit - 17
Pittsburgh - 13
I've tried various methods to add the count in Arcade and the regular default editor - Count($datapoint.objectid), Count($datapoint.site), Count($datapoint["objectid"]), etc., with no luck. I'd think this would be simple, but maybe I'm the simple one.
Using ArcGIS Enterprise, whatever version is just before 11.
Thanks!
Solved! Go to Solution.
Thanks @jcarlson .
Does this go in the Advanced Formatting section of the List widget? I keep getting the error 'Parse Error:featuresetbyportalitem is not available', and sure enough, the Functions list says that this function is 'Not available'.
This is running on a state Enterprise Portal where my User Type = Creator, and Role = Publisher. Could this be a permissions issue, an Enterprise configuration issue, something else along those lines, or do I create the expression elsewhere?
Thanks for the github link as well, very handy!
Getting a List to show aggregated features will require a Data Expression. Once a layer hits the List, any Arcade you use is being evaluated per-feature, so the aggregation needs to happen a step earlier. Fortunately, what you're describing here is pretty simple.
You can find a bunch of examples here: arcade-expressions/dashboard_data at master · Esri/arcade-expressions (github.com)
And here's what this situation might look like specifically.
var portal = Portal('https://www.arcgis.com');
var fs = FeatureSetByPortalItem(
portal,
'your layer itemid',
0,
['site'],
false
);
return GroupBy(
fs,
'site',
{name: 'site_count', expression: 1, statistic: 'SUM'}
)
Thanks @jcarlson .
Does this go in the Advanced Formatting section of the List widget? I keep getting the error 'Parse Error:featuresetbyportalitem is not available', and sure enough, the Functions list says that this function is 'Not available'.
This is running on a state Enterprise Portal where my User Type = Creator, and Role = Publisher. Could this be a permissions issue, an Enterprise configuration issue, something else along those lines, or do I create the expression elsewhere?
Thanks for the github link as well, very handy!
It would be a new layer. When you're selecting the data source for your list, you should be presented with the option to create a new Data Expression. That's where this would go.
Once again, thanks so much @jcarlson ! This is what worked:
var ptl = Portal('https://gisportal...../portal/')
var fs = FeatureSetByPortalItem(
ptl,
'a92f7b3a792........................',
0,
['csv_site'],
false
);
return GroupBy(
fs, ['csv_site'],
{name: 'site_count', expression: 'csv_site', statistic: 'COUNT'}
)