Help with IIF statement

1130
3
Jump to solution
02-17-2017 08:31 PM
MikeOnzay
Occasional Contributor III

I'm trying to build a nested IIF statement in a dynamic table that will populate a field I'm using to show an image in my popup window on Portal.

Works: 

IIF([MUTCD_ID]="UNK", "no image",IIF([SIGN_CATEGORY]=1,"regulatory","no image"))

Doesn't work: 

IIF([MUTCD_ID]="UNK", "no image",IIF([SIGN_CATEGORY]=1,"regulatory/[MUTCD_ID]","no image"))

Row Info
Row Number 2
TableName: Sign
FieldName: EXISTING_IMAGE_LINK
ValueInfo: IIF([MUTCD_ID]="UNK", "no image",IIF([SIGN_CATEGORY]=1,"regulatory/[MUTCD_ID]","no image"))
ValueMethod: EXPRESSION
On Create: 0
On Change: 0

Checking for Subtype Restriction
Field Name: EXISTING_IMAGE_LINK was found at index: 31
Trying: EXPRESSION
replace field: SIGN_CATEGORY with a value
replace field: MUTCD_ID with a value
replace field: MUTCD_ID with a value
Checking to verify there is a field to store the expression
Expression to be eval: IIF("R7-1"="UNK", "no image",IIF(1=1,"regulatory/"R7-1"","no image"))
ERROR: evaluating the expression for feature in Sign with OID of 10419
Expected ')'
Finished: EXPRESSION

I don't know why it is expecting a closed parentheses. I've tried various things and it keeps throwing out this same error. The expression that works has the same number of parentheses. 

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MikeMillerGIS
Esri Frequent Contributor

Change this

Doesn't work:

IIF(="UNK", "no image",IIF(=1,"regulatory/" & ,"no image"))

you need to concatenate the variable and the string, might be a + instead of &, I am rusty on VB

Sent from my Verizon Wireless 4G LTE DROID

View solution in original post

0 Kudos
3 Replies
JoeBorgione
MVP Emeritus

Have you looked at the offending feature with OID 10419?  Purely a WAG (wild a$$ guess).  Is there a <null> value where there shouldn't be?

That should just about do it....
0 Kudos
MikeMillerGIS
Esri Frequent Contributor

Change this

Doesn't work:

IIF(="UNK", "no image",IIF(=1,"regulatory/" & ,"no image"))

you need to concatenate the variable and the string, might be a + instead of &, I am rusty on VB

Sent from my Verizon Wireless 4G LTE DROID

0 Kudos
MikeOnzay
Occasional Contributor III

In response to the first reply I recreated the scenario in a file GDB with 3 columns to eliminate any other possibilities. The image below is showing the field alias and I still received the same error.

In response to your suggestion of concatenating the string and variable I get the same error. 

ValueInfo: IIF([MUTCD_ID]="UNK", "no image",IIF([SIGN_CATEGORY]=1,"regulatory/"&[MUTCD_ID],"no image")

Expression to be eval: IIF("R7-1"="UNK", "no image",IIF(1=1,"regulatory/"&"R7-1","no image")
ERROR: evaluating the expression for feature in sign with OID of 1
Expected ')'

It turns out that using + as a concatenation operator is valid in VBA for numbers AND strings. It worked.

ValueInfo: IIF([MUTCD_ID]="UNK", "no image",IIF([SIGN_CATEGORY]=1, "regulatory/"+[MUTCD_ID],"no image"))

What really started me down this path was wanting to force the value to lowercase. It works now.

IIF([MUTCD_ID]="UNK", "no image",IIF([SIGN_CATEGORY]=1, "regulatory/"+LCase([MUTCD_ID]),"no image"))

Setting Value to: regulatory/r7-1

Thanks!

0 Kudos