Problem using IIf in Arcade label expression to check if field is Null

1338
4
Jump to solution
02-22-2022 03:39 PM
MattSmith6
New Contributor III

Trying to label this feature class on it's Name field. If the Name field is Null then I want to place custom text.

This is what I have:  

var name = $feature.name

IIf(IsEmpty(name) == False, name, 'landing ground')

But it only seems to label the True part of the statement and not the False, so I see the name, but not the text "landing ground" (image 2).

This seems really basic stuff, so can't work out why it's not working like I think it should.

MattSmith6_1-1645573060518.png

MattSmith6_0-1645572891887.png

 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
jcarlson
MVP Esteemed Contributor

IsEmpty evaluates to a boolean, and "!" negates a condition, so you can re-write that as

Iif(!IsEmpty(name), name, 'landing ground')

 But what you're essentially doing is replicating the function DefaultValue. Try this:

DefaultValue(name, 'landing ground')
- Josh Carlson
Kendall County GIS

View solution in original post

4 Replies
jcarlson
MVP Esteemed Contributor

IsEmpty evaluates to a boolean, and "!" negates a condition, so you can re-write that as

Iif(!IsEmpty(name), name, 'landing ground')

 But what you're essentially doing is replicating the function DefaultValue. Try this:

DefaultValue(name, 'landing ground')
- Josh Carlson
Kendall County GIS
MattSmith6
New Contributor III

Thanks @jcarlson but that's yielding the exact same result. I'm still missing labels for records with the Null value

0 Kudos
MattSmith6
New Contributor III

OK, clearly I wasn't awake! I had a SQL limiting which records were being returned. Rookie error.

Thanks for your help!

0 Kudos
jcarlson
MVP Esteemed Contributor

Ah! That was my next question! Always nice when it's a simple solution.

- Josh Carlson
Kendall County GIS
0 Kudos