I have an Arcade data expression for an indicator widget in a dashboard. It returns a count of distinct sites in a feature layer in our Enterprise Portal. It works correctly in the expression editor, but in the layer selection section the expression has an error icon stating 'Unable to execute Arcade Script'. Any ideas why this won't work, and how to get it to work? Seems like it should be simple. Thanks!
I based this off of Josh's ( @jcarlson ) answer in https://community.esri.com/t5/arcgis-web-appbuilder-questions/finding-distinct-features-using-arcade...
var portal = Portal('https://ourportal/');
var fs = FeatureSetByPortalItem(
portal,
"item_id",
0,
['site'],
false
);
return Count(Distinct(fs, 'site'))