I am looking to create an expression in Arcade using multiple "if/then" statements. The issue I am running into is trying to use "AND" in between statements. I currently have a flag if the bench is identical or not. It looks like this:
if ($feature.toe_target_caps==
$feature.target_formation) {return 1}
else {return 0}
What I need to do next is say
if target_formation = "NIOBRARA A" and toe_target_caps = "NIOBRARA B" = 2
if target_formation = "NIOBRARA B" and toe_target_caps = "NIOBRARA C" = 3
if target_formation = "NIOBRARA A" and toe_target_caps = "NIOBRARA C" = 4
else {return 0}
So ideally I would have flags 5 flags (0-4). Thanks!
Solved! Go to Solution.
You can try the following samples but there are a few holes in the logic from the sample you provided. For example "NIOBRARA A" and "CODELL", "NIOBRARA B" and "CODELL", "NIOBRARA B" and "NIOBRARA A", "CODELL" and "NIOBRARA A", etc. will all result in a return of 0. Is this what you wanted? If not, you can expand the conditional statements to include these as well. The first example use && for (and) and if was need || for (or).
if ($feature.target_formation == $feature.toe_target_caps){return 1}
if ($feature.target_formation == "NIOBRARA A" && $feature.toe_target_caps == "NIOBRARA B") {return 2}
if ($feature.target_formation == "NIOBRARA B" && $feature.toe_target_caps == "NIOBRARA C" ) {return 3}
if ($feature.target_formation == "NIOBRARA A" && $feature.toe_target_caps == "NIOBRARA C"){return 4}
else {return 0}
This second example has the same output but is based upon grouped and nested conditional statements
if ($feature.target_formation == $feature.toe_target_caps){
return 1
}
if ($feature.target_formation == "NIOBRARA A"){
if ($feature.toe_target_caps == "NIOBRARA B") {
return 2
}
else if ($feature.toe_target_caps == "NIOBRARA C" ) {
return 4
}
}
if ($feature.target_formation == "NIOBRARA B"){
if ($feature.toe_target_caps == "NIOBRARA C") {
return 3
}
}
else {return 0}
You can try the following samples but there are a few holes in the logic from the sample you provided. For example "NIOBRARA A" and "CODELL", "NIOBRARA B" and "CODELL", "NIOBRARA B" and "NIOBRARA A", "CODELL" and "NIOBRARA A", etc. will all result in a return of 0. Is this what you wanted? If not, you can expand the conditional statements to include these as well. The first example use && for (and) and if was need || for (or).
if ($feature.target_formation == $feature.toe_target_caps){return 1}
if ($feature.target_formation == "NIOBRARA A" && $feature.toe_target_caps == "NIOBRARA B") {return 2}
if ($feature.target_formation == "NIOBRARA B" && $feature.toe_target_caps == "NIOBRARA C" ) {return 3}
if ($feature.target_formation == "NIOBRARA A" && $feature.toe_target_caps == "NIOBRARA C"){return 4}
else {return 0}
This second example has the same output but is based upon grouped and nested conditional statements
if ($feature.target_formation == $feature.toe_target_caps){
return 1
}
if ($feature.target_formation == "NIOBRARA A"){
if ($feature.toe_target_caps == "NIOBRARA B") {
return 2
}
else if ($feature.toe_target_caps == "NIOBRARA C" ) {
return 4
}
}
if ($feature.target_formation == "NIOBRARA B"){
if ($feature.toe_target_caps == "NIOBRARA C") {
return 3
}
}
else {return 0}
That worked great, thank you Lance!
I am glad that worked.