Trying to create an Indicator with a data expression to sum values and apply calculations

497
2
Jump to solution
11-30-2023 12:16 PM
Labels (1)
BarryG
by
Occasional Contributor

I am trying to sum three fields (TOTAL_MKT_VALUE, NEAR_DIST_WATER, NEAR_DIST_SEWER), while applying a factor value to the last two fields, into a new Indicator, but I get an error message "Invalid variable assignment". The three fields are all of Double Precision type. Can anyone please help me figure out what is wrong with this expression (below)?

var out_fs = { geometryType: “”, fields: [ {name: “Value”, type: “esriFieldTypeDouble”}, ], features: [] }

var v1 = $datapoint[‘TOTAL_MKT_VALUE’]

var v2 = $datapoint[‘NEAR_DIST_WATER’] * 200

var v3 = $datapoint[‘NEAR_DIST_SEWER’] * 100

var v = v1 + v2 + v3 Push(out_fs.features, {attributes: {Value: v}})

return FeatureSet(Text(out_fs))

0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

The quotes you're using aren't the standard ' or ". Replace those and it should run properly.

var out_fs = { geometryType: '', fields: [ {name: 'Value', type: 'esriFieldTypeDouble'}, ], features: [] }

var v1 = $datapoint['TOTAL_MKT_VALUE']
var v2 = $datapoint['NEAR_DIST_WATER'] * 200
var v3 = $datapoint['NEAR_DIST_SEWER'] * 100
var v = v1 + v2 + v3; 
Push(out_fs.features, {attributes: {Value: v}})
return FeatureSet(Text(out_fs))

View solution in original post

2 Replies
KenBuja
MVP Esteemed Contributor

The quotes you're using aren't the standard ' or ". Replace those and it should run properly.

var out_fs = { geometryType: '', fields: [ {name: 'Value', type: 'esriFieldTypeDouble'}, ], features: [] }

var v1 = $datapoint['TOTAL_MKT_VALUE']
var v2 = $datapoint['NEAR_DIST_WATER'] * 200
var v3 = $datapoint['NEAR_DIST_SEWER'] * 100
var v = v1 + v2 + v3; 
Push(out_fs.features, {attributes: {Value: v}})
return FeatureSet(Text(out_fs))
BarryG
by
Occasional Contributor

Thank you Ken. I found out the problem is that my layer is a map image layer, and the Arcade script only works for Feature service layers.

0 Kudos