I am trying to create a pie chart in dashboard using arcade.
I am query a layer by a list of values and create some values for the pie.
The basic lines is
var sql = "GlobalID = '" + globalId + "'";
var featureLocation = Filter(fs_location, sql);
where the golbalID change in a loop.
It all works fine when the feature set contain values. The problem is when it return nothing.
I tried "isEmpty(featureLocation)" but it return an error.
I tried some simple loop:
var c = 0
for(var s in featureLocation)
{
c = c + 1
}
it return an error too.
Unlike many of the examples I do not have $feature here.
Any good way to understand nothing is coming back and does not get an error?
Thanks
If you expand the tollbar in the comment box, you can insert code samples:
Try this:
if(Count(featureLocation) == 0) {
// noting found, return null
return null
}
This appears to be a problem when filtering by GlobalID. If you put in a filter clause on a field that returns no values (like "var filter = Filter(fs, 'objectid = 0')"), the filter count is 0.
Hi
I found out that when the globalID is empty you get an error.
Still the expression GlobalID = '' is valid but any reference to the featureSet it returns (including Count) return an error.
Have you tried checking for null?
if(featureLocation == null || Count(featureLocation) == 0) {
// noting found, return null
return null
}