I have an Arcade data expression I'm trying to set as the source for an indicator widget in a dashboard on our Enterprise Portal. This expression should return a count of distinct sites in a hosted feature layer, e.g. 5 distinct sites from 684 records.
The expression below works in the expression editor, returning a Number type of 5, but the Source tab shows an error icon with the message 'Unable to execute Arcade expression'. It seems like this should be a relatively simple expression. All clues and help appreciated, thanks.
Credit to @jcarlson, expression based on answer here.
var ptl = Portal('https://portal_url/')
var fs = FeatureSetByPortalItem(
ptl,
'itemid',
0,
['site'],
false
);
return Count(Distinct(fs, 'site'))