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'))
Solved! Go to Solution.
Data expressions need to return a FeatureSet. The Indicator can handle the Count portion, so just return Distinct(fs, 'site'), then configure the widget.
Data expressions need to return a FeatureSet. The Indicator can handle the Count portion, so just return Distinct(fs, 'site'), then configure the widget.
Thanks! Works great. Don't know why it worked in the expression editor but not elsewhere, but good enough.
Well, the expression editor will return anything so long as the expression is valid. You could have the expression Boolean() and it would return a value. It's when the expression is being loaded by the Dashboard that it looks for the FeatureSet.
Similarly, the Popup editor will return a FeatureSet, but when the popup evaluates the expression, it's looking for something it can render as text or HTML, and a FeatureSet will just show up as [Object object] or something.