Data Expressions for Dashboard's List widget is a joy!
The following code works well but only returns Domain Codes.
Can DomainName($feature, 'Trap_Region') somehow be used to get Domain Names?
var portal = Portal('https://www.arcgis.com/');
var fs = FeatureSetByPortalItem(
portal, 'XXXXXXXXXXXXXXXXXXXXXXX',
1,
['Trap_ID','Trap_Region'],
false
);
// Trap count grouped by trap region
var fs_gp = GroupBy(fs, ['Trap_Region'], [{name: 'Total_Traps', expression: 'Trap_ID', statistic: 'COUNT' }]);
return fs_gp
Thanks for the code, it worked great for me. I was not able to figure out how to get the domain names either but I did find in the dashboard editor (under slices for pie chart) that you could change the label for the categories manually. Hope that helps.