Arcade "Distinct" Expression Troubles

05-22-2019 12:09 PM
Occasional Contributor


I have a layer of parcel building sketches where each part of the building is a separate feature/record (over 259,000 features).  This means the porch is one feature, the house another, the garage is a third feature, etc.  I have a Parcel ID field (my primary key) that I need a count of unique values to get the summary total of parcels (not building sketch parts) for the county.  The goal is to get the parcels summary total when you click on the county boundary in a pop-up.  Then I can display this in the Details element of Dashboard.  I do know I can get this information from ArcPro but the ultimate goal is to filter this data to display only the sketches that have been QA/QC reviewed by another department (it is a field in the parcel building sketches layer).  They (department heads) want to see a live update of the number of parcels that have been reviewed on a continuous basis since its being reviewed by 6-8 people on a daily basis.

I am using this code but only get back a value of "1".  

var sketchesReviewed = FeatureSetByName($map,"Building_Sketch_Check", ["parid"]);
var distinctSketches = Distinct(Intersects((sketchesReviewed), $feature))
var countSketches = Count(distinctSketches)
return countSketches


Any suggestion or help on where I am going wrong would be greatly appreciated.  This code is written on the county boundary layer since that is the layer I want to configure the pop-up on.  Thanks!

0 Kudos
1 Reply
Esri Esteemed Contributor

Hi Angelia Hagopian ,

I'm not sure if this is something you should do, if the query will be performed on a layer with 259,000 features. Performance will probably become an issue. If you have a layer that is filtered in such a way to reduce the number of features, that will probably reduce the problem.

Intersects will return an array of features that intersect, and in this case each feature will have an attribute. I'm not sure if there is an easy way to get an array of all the attribute values and apply the distinct on that. You could try something like this:

var sketchesReviewed = FeatureSetByName($map,"Building_Sketch_Check", ["parid"]);
var intersectSketches = Intersects(sketchesReviewed, $feature);
var parids = [];
for (var feat in intersectSketches) {
    if (IndexOf(parids, feat.parid) == -1) {
        parids[Count(parids)] = feat.parid;

return Count(parids);
0 Kudos