Arcade expression to calculate total area of impervious surface in a selected parcel

999
1
Jump to solution
12-09-2020 01:17 PM
Labels (1)
ChristyWest10
New Contributor

I am attempting to write an Arcade expression in a pop up on the Parcels feature layer to calculate the total square feet of intersecting impervious surface for each parcel. Here is my code: 

var myParcelID = $feature["PARCEL_ID"];

var iaFeatures = FeatureSetByName($map,"Impervious Surfaces",["PARCELID"], true);

var iaParcels = Filter(iaFeatures, "PARCELID = myParcelID");

var totalArea = Area(iaParcels, "square-feet");

return totalArea.

This is the error I get when I test it: Execution Error:Failed to execute query.

I would like some help understanding what part of my code isn't working and why. The error message gives me no clue and doesn't highlight any of the lines or place an x beside any of them as it does with syntax errors. Thanks in advance.

 

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

This line is a problem

var iaParcels = Filter(iaFeatures, "PARCELID = myParcelID"); 

myParcelID is a variable. It should look like this

var iaParcels = Filter(iaFeatures, "PARCELID = " + myParcelID); //if myParcelID is a number
var iaParcels = Filter(iaFeatures, "PARCELID = '" + myParcelID +"'");  //if myParcelID is a string

View solution in original post

1 Reply
KenBuja
MVP Esteemed Contributor

This line is a problem

var iaParcels = Filter(iaFeatures, "PARCELID = myParcelID"); 

myParcelID is a variable. It should look like this

var iaParcels = Filter(iaFeatures, "PARCELID = " + myParcelID); //if myParcelID is a number
var iaParcels = Filter(iaFeatures, "PARCELID = '" + myParcelID +"'");  //if myParcelID is a string