Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run a rather lengthy model (built in ArcGIS 9.3.1) in ArcGIS 10.1 and I'm recieving an error on a Calculate Field tool. The error is - Type mismatch: 'iif'.

This error is refering to an expression in the tool: iif(IsNull( [PID] ) ,NA,[PID]).

enter image description here

I tried "if" instead of "iif" but then recieved a generic error.

I never had this issue when running the model in 9.3.1. I'm not sure what to do here. Any suggestions?

share|improve this question
did you try quoting NA? – Kirk Kuykendall Mar 1 '13 at 18:50
up vote 3 down vote accepted

You can't use iif directly in field calculator expressions, you need to use the code block. There are some examples on the Field Calculator Examples help page.



Expression Type:

Code Block:
def Reclass(WellYield):
    if (WellYield >= 0 and WellYield <= 10):
        return 1
    elif (WellYield > 10 and WellYield <= 20):
        return 2
    elif (WellYield > 20 and WellYield <= 30):
        return 3
    elif (WellYield > 30):
        return 4



Expression Type:

Code Block:
Dim density
If [POP90_SQMI] < 100 Then
density = "low"

elseif [POP90_SQMI] < 300 Then
density = "medium"

density = "high"
end if
share|improve this answer
That would be VBScript, not VBA. VBA was removed from the Field Calculator at 10. IIF is a VBA function. The reason it's not working at 10.1 is that it doesn't exist in VBScript. Otherwise this is a good answer. – blah238 Mar 1 '13 at 18:55
Thank's guys. For dummies like me, how would you go about writing the code block. Sorry for being such a vampire, I don't know much about coding. – dchaboya Mar 1 '13 at 19:05
This worked, thanks dmahr. And thanks to nmpeterson for spoon feeding me the code block. – dchaboya Mar 5 '13 at 17:30

As dmahr said, you have to use a codeblock. In your case, that would be something like this, using Python:

def null_to_NA(field):
    if field == None:
        return 'NA'
        return field

And then the expression would be:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.