This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
I am getting a 'malformed if statement' error on the below sequence - can anyone assist? I think its with my "then if" statement... not sure that that nesting is possible.
if [curstat]=(1 OR 2 OR 3 OR 4 OR 5 OR 6 OR 7) then ([curstat]-1) else if [curstat]=(8 OR "S" OR "B" OR "L" OR "W") then 7 else if [curstat]="N" then (if ([DAYS_DEL]>=90 AND [DAYS_DEL]< 119) then 4 else if ([DAYS_DEL]>=120 and [DAYS_DEL]<149) then 5 else 6 endif endif) else 0 endif endif
First of all, you should use the "elseif" expression without a whitespace, in a single word.
Second, you're mixing types in your expression
The field [curstat] must be a numeric or a string field, it can't be both. You cannot use math operations like "[curstat]-1" if you have strings on it. So I recommend you filtering numbers, change field type to numeric, doing the math operation with your formula, and then union the records again as strings, to finally apply your full expression.
Your if statement had some extra "endifs" on it, so I also corrected that.
if [curstat]=(1 OR 2 OR 3 OR 4 OR 5 OR 6 OR 7) then ([curstat]-1) elseif [curstat]=(8 OR "S" OR "B" OR "L" OR "W") then 7 elseif [curstat]="N" then (if ([DAYS_DEL]>=90 AND [DAYS_DEL]< 119) then 4 elseif ([DAYS_DEL]>=120 and [DAYS_DEL]<149) then 5 else 6 endif) else 0 endif
If you post your full workflow or your sample data, I'd be glad to work on a solution for you.
If they are numeric fields (like Int16, Int32, Double), the letters will be shown up as Nulls, since they are not numbers.
Like I said, you have to treat things separately.
Define the field as a string, filter numbers, change to numeric, apply your math, change back to string and then use the Union Tool to join the records back together (numbers and string), to compare each other with your full formula.
I don't think that is the issue, because when I pull those nested if statements out into a new line, they operate correctly. Using your formula, I am now getting an "invalid type in operator --." error