0

I am looking for an Arcade Expression for ArcGIS Online which does the following:

If the value from field A is 222,333 or 444 OR
If the value from field B is 222,333 or 444 OR
If the value from field C is 222,333 or 444
return "Problem detected"
else return "Everything fine"

I have just found a solution for one field, but it does not take care of Field B or field C:

if ( $feature.FieldA == 111) {
return "everything fine"
}
else if ( $feature.FieldA == 222) {
return "Problem detected"
}
else if ( $feature.FieldA == 333) {
return "Problem detected"
}
else if ( $feature.FieldA == 444) {
return "Problem detected"
}
else {
return "No Values"
}

Is this even possible in Arcade?

asked Aug 18, 2021 at 9:09

2 Answers 2

3

A solution is to use a nested IIF() statement. Imagine the data is this:

Input

Then you would run the following field calculate on it using this scripting logic:

var problemValues = [222,333,444];
var v = iif(($feature.fA == 111 && $feature.fB == 111 && $feature.fC == 111), "OK", iif((indexOf(problemValues,$feature.fA) != 0 && indexOf(problemValues,$feature.fB) != 0 && indexOf(problemValues,$feature.fC) != 0),"no values","problem"));
return v;

The result being:

Results

answered Aug 19, 2021 at 16:39
0

I suggest the following expression:

var problemValues = [222,333,444];
var fields = [
 $feature.fieldA,
 $feature.fieldB,
 $feature.fieldC
];
for (var i in fields){
 var v = fields[i];
 if(IndexOf(problemValues, v) > -1){
 return 'Problem detected';
 }
}
return 'Everything fine';

It's a little easier to read, and definitly easier to modify if you want to update the problem values.

answered Sep 9, 2023 at 0:32

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.