Select to view content in your preferred language

Arcade Display Expression Builder

629
2
Jump to solution
06-28-2023 02:54 PM
JosephPilkington1
Emerging Contributor

I am trying to create a simple Display Expression in Expression Builder using Arcade. I want the expression to return the Unit, unless it is null, if null I want it to then display Building, unless that is null, if null I want it to finally display the Room. So far, my expression returns Unit, but nothing past that. What am I doing wrong?

return $feature.Unit;
if(isempty ($feature.Unit)){
return $feature.Building
}
else if(isempty ($feature.Building)){
return $feature.Room
}

0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

return will end your expression. Since that first line has a return that is not within a conditional block, it will always run, and your expression will end at line 1.

Just put that line in its own if section:

if (!IsEmpty($feature.Unit)) {
  return $feature.Unit
} else if (!IsEmpty($feature.Building)) {
  return $feature.Building
} else if (!IsEmpty($feature.Room)) {
  return $feature.Room
}
- Josh Carlson
Kendall County GIS

View solution in original post

2 Replies
jcarlson
MVP Esteemed Contributor

return will end your expression. Since that first line has a return that is not within a conditional block, it will always run, and your expression will end at line 1.

Just put that line in its own if section:

if (!IsEmpty($feature.Unit)) {
  return $feature.Unit
} else if (!IsEmpty($feature.Building)) {
  return $feature.Building
} else if (!IsEmpty($feature.Room)) {
  return $feature.Room
}
- Josh Carlson
Kendall County GIS
JosephPilkington1
Emerging Contributor

Ah! Makes sense. Thank you!! I knew something was wrong, I just couldn't figure it out. Much appreciated!

0 Kudos