# Average from feature set using a variable?

Question asked by owenmt8656 on May 19, 2020

Goal: Create a feature set from an intersection of another layer then filter based on a field value. From there I need to define a numeric score value from a string, and finally return the average of the numeric score from the feature set .

The issue I'm having is getting just the feature set to calculate the average for.

``//Finds the Neighborhood Polygon that intersects with Selected Parcelvar intersectArea = Intersects(FeatureSetByName(\$map,"Neighborhoods"), \$feature);//Defines the field to match and set the filter with var nbhd = \$feature.NBHD;//Filters all parcels with the same NBHD as the selected featurevar filterresult = Filter(\$layer, 'NBHD = @nbhd');//This returns the feature set I would like to assign a variable to and calculate an average from``

CDU is the field I would like to add a numeric score to average:

``if (CDU=="FAIR"){    var cduVal = 1.25} else if     (CDU=="AVERAGE"){     var cduVal = 1.5} else if    (CDU=="EXCELLENT"){     var cduVal = 2.5} else if    (CDU=="EXTREMELY POOR"){     var cduVal = 0.0} else if    (CDU=="GOOD"){     var cduVal = 2} else if     (CDU=="POOR"){     var cduVal = 1} else if    (CDU=="UNSOUND"){     var cduVal = 0.25} else if    (CDU=="VERY GOOD"){     var cduVal = 1.5} else if    (CDU=="VERY POOR"){     var cduVal = 0.75}else {var cduVal = 0}return Average(cduVal);``

If that makes any sense...

Any help would be appreciated.