Arcade Expression - creating an incremental array of non nulls

732
1
02-21-2020 05:21 AM
LukeHaskett
New Contributor

Hi,

Arcade is still very new to me so forgive me if this seems like a basic error. I'm trying to use arcade to loop through the rows of a feature class and return the number of non-null fields for each row. I'm using the following code but it just produces the number of items in the array (3) for each row:

var array = [$feature.Welcoming,$feature.Access,$feature.Community];
var total = 0;
   for(var k in array){
      Iif(isempty(k),total+=0,total+=1);
}
return total

Would really appreciate some pointers, I can't seem to crack this. So for instance, in a row where two of the variables in the 'array' were null I would expect/need it to return '1' (the number of non-nulls)... equally if one of the variables were null I would need it to return '2'.

Thanks!

0 Kudos
1 Reply
XanderBakker
Esri Esteemed Contributor

Hi Luke Haskett ,

Have a look at this post by JPC_Planning  and my answer there: Using Arcade to count nulls or non-nulls from an array 

0 Kudos