Hello everyone! I am looking for some help with writing an Arcade Expression. I have tried using If Else statements, but my results do not seem to be adding about. For example, I trying to trying an expression that goes through multiple fields (see table below) and finds the word "NO". Next, if any of the fields have "NO" in them, the new field will say "Non Compliant".
Thank you!
Best,
Janelle
Solved! Go to Solution.
The way to do that is to make a list of the fields you want to check and loop through that list to check if that field contains "No". You'll have to use the Expects function when using a variable for the field name.
Expects($feature, 'field1', 'field2', 'field3') //replace these with your field names
var fields = ['field1', 'field2', 'field3'] //replace these with your field names
var compliance = 'Compliant'
for (var i in fields) {
if ($feature[fields[i]] == 'No') compliance = 'Not Compliant' //This is case sensitive, so 'NO' does not equal 'No'
}
return compliance
The way to do that is to make a list of the fields you want to check and loop through that list to check if that field contains "No". You'll have to use the Expects function when using a variable for the field name.
Expects($feature, 'field1', 'field2', 'field3') //replace these with your field names
var fields = ['field1', 'field2', 'field3'] //replace these with your field names
var compliance = 'Compliant'
for (var i in fields) {
if ($feature[fields[i]] == 'No') compliance = 'Not Compliant' //This is case sensitive, so 'NO' does not equal 'No'
}
return compliance
Thank you!