Hello,
I have an expression I'm trying to solve when bringing a service into a dashboard list.
I'd simply link to see values where 'CleanoutNeeded = Yes' and then I want to group them so I only have a single item in my resulting list for 'CleanoutNeeded'. My code returns an empty featureSet and no errors as displayed below. The documentation indicates that a SQL expression with text can be used to satisfy the filter but it doesn't work here. If I comment out the Filter() function, the GroupBy function returns both 'Yes' and 'No' values in the cleanout needed field as expected.
var portal = Portal('hhts://www.arcgis.com');
var fs = FeatureSetByPortalItem(
portal,
'29fb497ebe1c47079a5f3f37013bfff9',
1,
[
'CleanoutNeeded'
],
False //don’t include geometry
);
var co = Filter(fs, 'CleanoutNeeded = Yes')
return co
return GroupBy(co, ['CleanoutNeeded'],
[{name: 'CleanoutNeeded', expression: 'CleanoutNeeded', statistic: 'Count'}])
Any idea on how this can be achieved? Thanks in advance.
Zac
To post code:
Your SQL query is wring. CleanoutNeeded is a string field, so the query should look for a string (enclosed in single quotes).
var co = Filter(fs, "CleanoutNeeded = 'Yes'")
Thank you - I knew it was something small.
Can you explain why you'd want a single-item list? What you're trying to do could easily be done with an Indicator widget using its off-the-shelf configuration, and would not require a Data Expression at all.