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?


2 Answers 2


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
  • 1
    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, 2013 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, 2013 at 19:05
  • This worked, thanks dmahr. And thanks to nmpeterson for spoon feeding me the code block.
    – dchaboya
    Mar 5, 2013 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:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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