In Pro 3.3, I have a set of cities whose names I want to label based on two fields, NAME and NAMEALT. If the city has a NAMEALT, I want to use that name. If it does not, I want to default to NAME. I thought that by using defaultValue in Arcade (see screenshot), it would return the NAME value if no NAMEALT value was detected. What am I doing wrong?
I did a few tests and the syntax appears to be correct. The value field might have invisible blank spaces that could cause the problem. Python lstrip() can remove leading blank spaces.
I think @BarryNorthey is right. See below, where my third point, OBJECTID 7, does not show because the whole field is just spaces (so it is labeling, but it's unseen because it's spaces!).
An alternative to the suggestion above using Python would be to improve your label expression to TRIM white space.
// Use Trim() to reduce a field full of spaces down to "".
DefaultValue(Trim($feature.Label_Main), $feature.Label_Backup)
And now here is what we have, because the "Label_Main" values is reduced from " " down to "", and therefore is considered Empty, and then defaults to the Label_Backup.