Hi,
I am trying to use the list widget in AGOL dashboard to create a species list for a layer I have containing species data. I want the list to only include the name of each species once and show a sum of total counts. I've done this by using a data expression using the code below, but have two issues I'm struggling to solve:
var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), 'featureid', 0, ['Location','CommonNameNE','PrimaryCountValue'], false); return GroupBy(fs, ['CommonNameNE'],
[{name: 'Total_Observations', expression: 'PrimaryCountValue', statistic: 'SUM' }]);
1) The species field uses a domain list, and its currently showing the code rather than the label. How do I get it to pull out the label? (I assume its somehow using 'DomainName(feature, field)'. But can't work out where to put this in the code and what the 'feature' part should be? $feature, $datapoint, my fs variable?.
2) I also would like other fields from the data to be available in the data expression to enable me to filter the list in the dashboard e.g. by location etc. But again can't work out how to include these in the script so they are pulled out but not used to group the list by.
Any help on either/both of these would be amazing,
Thank you