Attribute Assistant Nested IIF

809
3
Jump to solution
10-18-2017 08:03 AM
Labels (1)
JoeBorgione
MVP Emeritus

Having looked at a number of posts on this subject, I'm still miffed as to the logic of a nested IIF.  Basically, I want an if, elseif statement that would look like this:

If condition 1:

  do this...

Elseif condtion2:

  do something else

Simple enough, right?!

Here is my actual situation:  I capture the login of a user, and based on that login, aa needs to assign one of 4 initial strings. With one iff:

IIF([Operator] = "JBorgione","JVB,"")    ### my login, changes to my initials, at this stage a different login would leave it                                                                ### blank

With a second iif, it fails:

IIF([Operator]="JBorgione","JVB",IIF([Operator] = "TCurtis","TMC"))  ### if I don't login but TCurtis does....

Here's what the log file tells me:

ValueInfo: IIF([Operator]="JBorgione","JVB",IIF([Operator] = "TCurtis","TMC"))

.....

replace field: Operator with a value
Checking to verify there is a field to store the expression
Expression to be eval: IIF("JBorgione"="JBorgione","JVB",IIF("JBorgione" = "TCurtis","TMC"))
ERROR: evaluating the expression for feature in MasterStreetNameFC with OID of 26039
System.ArgumentException: Wrong number of arguments or invalid property assignment: 'IIF'

Obviously, I'm unsure of what I need to do to satisfy the requirements.

mmiller-esristaff

monzay‌  (I think you used to be user monzay, disregard if not...)

stonejd

That should just about do it....
0 Kudos
1 Solution

Accepted Solutions
MikeMillerGIS
Esri Frequent Contributor

Make sure to follow the statement, what to do when true, what to do when false syntax.

IIF([Operator]="JBorgione","JVB",IIF([Operator] = "TCurtis","TMC",You are missing what I do when I am false))

View solution in original post

3 Replies
MikeMillerGIS
Esri Frequent Contributor

Make sure to follow the statement, what to do when true, what to do when false syntax.

IIF([Operator]="JBorgione","JVB",IIF([Operator] = "TCurtis","TMC",You are missing what I do when I am false))

JoeBorgione
MVP Emeritus

Cool thanks.  It'll be a total of five iif's, so the last one will get the false statement, right?

This works.  At least it changes my login to my initials....

IIF([Operator]="JBorgione","JVB",IIF([Operator] = "TCurtis","TMC",IIF([Operator]="TBain","TXB",IIF([Operator]="BLeCheminant","BRL",IIF([Operator]="TARasmussen",TAR,"")))))

That should just about do it....
0 Kudos
JenniferStone
New Contributor III

Try this...

IIF([Operator]="JBorgione","JVB",IIF([Operator]="TCurtis","TMC",IIF([Operator]="JStone","JDS",IIF([Operator]="DBriggs","DAB",IIF([Operator]="FSunshine","FLS",Nothing)))))

Replacing the JStone, JDS, DBriggs, DAB, FSunshine, FLS of course. I use this format to modify my municipal codes, swis codes, and municipal abbreviations without a problem. Entering [#] may also work as the last false statement as it would just use the value that is already in there. I use [#] for all of my nested iif's accept the first of each process.

In this expression Nothing is used as the last false statement so that the system recognizes that it should be <Null>. Entering NULL as the last false statement would enter a text value of NULL. I have found that using "" also treats it as a text value, just blank.

Hope this helps! I have attached a screen shot of my iif statements so you can see what I'm talking about.

IIF statements for use in AA Dynamic Value table.