I am doing the lab called "Building an App in ArcGIS Online to Expand Food Access" but I am stuck on the "Customize pop-ups with arcade" exercise at step 4.
What needs to be done is to create a list of retail stores that are both within a .75 mile radius and accept SNAP. This is done using two expressions. The first expression creates a radius variable using the buffer function. This is what I have, which is exactly what the lab example shows (with a different layer ID).
The Count function cannot take a null, so you'll have to check if the Intersects function returns a null.
var retail_layer = FeatureSetById($map, "18d1d756020-layer-70");
var radius = Buffer($feature,.75,"miles");
var result = Intersects(retail_layer, radius);
if (IsEmpty(result)) return 'No features found';
var retail_count = Count(result);
return retail_count;
The second code worked as expected in my testing (changing the layer id and the field for the retail list)