AnsweredAssumed Answered

How to add multiple If/else statements in arcade?

Question asked by Blake_Liss on Oct 10, 2019
Latest reply on Oct 11, 2019 by xander_bakker

Hello All,

 

I am trying to write a script with multiple If/else statements because I am needing to calculate a field with multiple fields, but some of these fields have null values. The script I have is:

 

$feature.AddressNumber + $feature.AddNum_Suf + " " + $feature.StreetNamePreDirectional + " " + $feature.StreetNamePreType + " " + $feature.StreetName + " " + $feature.StreetNamePostType + "," + " " + $feature.PostalCommunityName + " " + $feature.PostalCode

if (IsEmpty($feature.AddressNumber)){
return ""
} else {
return $feature.AddressNumber
}
if (IsEmpty($feature.AddNum_Suf)){
return ""
} else {
return $feature.AddNum_Suf
}
if (IsEmpty($feature.StreetNamePreDirectional)){
return ""
} else {
return $feature.StreetNamePreDirectional
}
if (IsEmpty($feature.StreetNamePreType)){
return ""
} else {
return $feature.StreetNamePreType
}
if (IsEmpty($feature.StreetName)){
return ""
} else {
return $feature.StreetName
}
if (IsEmpty($feature.StreetNamePostType)){
return ""
} else {
return $feature.StreetNamePostType
}

 

The problem I am having is that the script is only returning the "$feature.AddressNumber". I am very novice with scripts but am stuck with what to do on this one. Any help is appreciated.

Outcomes