Select to view content in your preferred language

Data Expression in Dashboards

748
3
03-22-2023 08:04 PM
Labels (1)
ZacharyStanley
Occasional Contributor

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

 

 

0 Kudos
3 Replies
JohannesLindner
MVP Frequent Contributor

To post code:

JohannesLindner_0-1677736512957.png

JohannesLindner_1-1677736529803.png

 

 

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'")

Have a great day!
Johannes
0 Kudos
MarinGIS_Admin
New Contributor

Thank you - I knew it was something small.

0 Kudos
jcarlson
MVP Esteemed Contributor

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.

- Josh Carlson
Kendall County GIS
0 Kudos