Hi
I am in the process of creating a attribute rule and are having some issues notably with the Filter function in arcade.
The attribute rule is assigned to a polygon feature class (Terminal Serving Areas) so that when a polygon is created or edited it calculates the number of features form another point feature class (Service Points) that intersect the polygon and writes the count to a field on the polygon. I can get this to work easily with the following arcade:
var servicePoints = FeatureSetByName($datastore, "gs_service_point", ["audit_complete"], True);
var servicePointsIntersect = Intersects(servicePoints, $feature);
return (Count(servicePointsIntersect))
However the Service Points have a filed (audit_complete) and I want to be able to filter the Service Points so that only certain "types" are counted. In my case the filter is where audit_complete <> 'DNE'
So I change my arcade to include the filter:
var servicePoints = FeatureSetByName($datastore, "gs_service_point", ["audit_complete"], True);
var servicePointsIntersect = Intersects(servicePoints, $feature);
var servicePointsFilter = Filter(servicePointsIntersect, "audit_complete <> 'DNE'");
return (Count(servicePointsFilter))
But I cannot get it to work. No matter what I do it always returns zero! I have tried everything I can think of!!
Does anyone have any idea how to get the filter to work? It may be worth noting that the audit_comple filed contains a lot of null values but this should not impact on the query..
cheers
Callum
Solved! Go to Solution.
Hi
I am also seeing some strange behavior with the IS statement. It is converted to ISS just like i your case. Maybe not the best solution, but you could do this:
var servicePoints = FeatureSetByName($datastore, "gs_service_point", ["axin_audit_complete"], True);
var servicePointsIntersect = Intersects(servicePoints, $feature);
var cnt = 0;
for (var sp in servicePointsIntersect) {
if (sp.axin_audit_complete != "DNE") {
cnt += 1;
}
}
return cnt;
That seems to be working and no need to query for the Null values (although you could do this using IsEmpty).
After Further investigation it seems that the null values are the issue. The query "audit_complete <> 'DNE'" does not pick up null values? Dont know why but null is not DNE so those null records should be picked up.
So I have tried to update my Filter query as follows:
var servicePointsFilter = Filter(servicePointsIntersect, "audit_complete <> 'DNE' OR audit_complete IS NULL");
However this causes a further issue where the arcade parser somehow interprets the "IS" statement as "ISS" ??? See the error message below
Not sure why is interprets the "IS" as "ISS"
cheers
Callum
Hi
I am also seeing some strange behavior with the IS statement. It is converted to ISS just like i your case. Maybe not the best solution, but you could do this:
var servicePoints = FeatureSetByName($datastore, "gs_service_point", ["axin_audit_complete"], True);
var servicePointsIntersect = Intersects(servicePoints, $feature);
var cnt = 0;
for (var sp in servicePointsIntersect) {
if (sp.axin_audit_complete != "DNE") {
cnt += 1;
}
}
return cnt;
That seems to be working and no need to query for the Null values (although you could do this using IsEmpty).
Thanks Xander. I appreciate your help on this one.
Yes your workaround works for me although I agree it is not ideal.
I guess there is a issue with the parser that is changing "IS" to "ISS"
cheers
Callum
I'm going to tag Kory Kramer to see if he knows about an issue related to using IS in a filter in Arcade in Pro.
There isn't anything I could find regarding IS being interpreted as ISS but I'm curious about the OR.
Logical or in Arcade is ||
https://developers.arcgis.com/arcade/guide/logic/#if-statements
Does that help?
Hi Kory, thanks for sharing, but we are not refering to the or in Arcade (javascript) but inside the string which is a SQL expression that the Filter function in Arcade uses. Have you tried that?
Hmm, OK. I just set this up and it validates and seems to return the correct value:
I'm in a daily build of Pro 2.4 so have not looked at this in an earlier version. It might be worth working with Tech Support if deep troubleshooting is required!
Thanks for testing Kory. At least it is good to know that it is working correctly in 2.4