You can do this with GroupBy, which outputs a FeatureSet, so it's nice and easy.
var fs = FeatureSetByPortalItem(
Portal('your portal url'),
'itemid of layer',
0,
['Pitch', 'ClubHouse', 'CarPark']
false
)
return GroupBy(
fs,
{name: 'noncomp', expression: "'Non-Compliant'"},
[
{name: 'Pitch', expression: "case when Pitch = 'Non_compliant' then 1 else 0", statistic: 'SUM'},
{name: 'ClubHouse', expression: "case when ClubHouse = 'Non_compliant' then 1 else 0", statistic: 'SUM'},
{name: 'CarPark', expression: "case when CarPark = 'Non_compliant' then 1 else 0", statistic: 'SUM'}
]
)
I'm not 100% sure the second parameter there will work, but if it does, this would be simplest. You could alternatively, build your FeatureSet from scratch, but you'd need to do three separate Sum functions for that.
- Josh Carlson
Kendall County GIS