I'm trying to build a dashboard list from a feature class that is a lot of polylines, something like this:
- Trail 1, State 1, District 1
- Trail 1, State 1, District 1
- Trail 1, State 1, District 2
- Trail 2, State 2, District 3
- Trail 2, State 2, District 4
- Trail 3, State 3, District 5
- Trail 3, State 4, District 6
- Trail 3, State 5, District 7
- Trail 3, State 6, District 8
- Trail 3, State 7, District 9
What I want the list to show is:
- Trail 1, 1 State(s), 2 District(s)
- Trail 2, 1 State(s), 2 District(s)
- Trail 3, 5 State(s), 5 District(s)
What I've got so far is:
var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), 'a454cf97c4264cd2b77f27175e01d3ba', 0, ['TRLNAME','STATE','CONG_DIST'], false);
return GroupBy(fs, ['TRLNAME'],
[{name: 'total_states', expression: 'STATE', statistic: 'COUNT' },
{name: 'total_districts', expression: 'CONG_DIST', statistic: 'Count' }]);
Which gives me

Which is giving me unique trails, but very clearly not the unique state, district for each trail.
How do I narrow down the expression to return unique states,districts for each trail? Not a programmer.....