Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.

Multi IF formula causing Parse Error

dmitkevich
6 - Meteoroid

Good day,

I created a helper Field [YearsTenure] and not trying to create another field to highlight Milestone Flag, but keep on getting Parse Error.  I tried these 2 options:

if [YearsTenure]=5 then '5' AND
if [YearsTenure]=10 then '10' AND
if [YearsTenure]=15 then '15' AND
if [YearsTenure]=20 then '20' AND
if [YearsTenure]=25 then '25' AND
if [YearsTenure]=30 then '30'
else 'Non Milestone'
endif

 

--------------------------------

if [YearsTenure]=5 then [YearsTenure] AND
if [YearsTenure]=10 then [YearsTenure] AND
if [YearsTenure]=15 then [YearsTenure] AND
if [YearsTenure]=20 then [YearsTenure] AND
if [YearsTenure]=25 then [YearsTenure] AND
if [YearsTenure]=30 then [YearsTenure] AND
if [YearsTenure]=35 then [YearsTenure]
else 'No Milestone'
endif

 

Also instead of 'number', I tried to insert [YearsTenure] to return the 5/10/15/etc if the value matches...

 

Can't figure out what am I doing wrong...I also tried switching from string to double/int that didn't fix the issue either.

6 REPLIES 6
Luke_C
17 - Castor

Hi @dmitkevich 

 

Try: 

if [YearsTenure]=5 then '5' ElseIf
[YearsTenure]=10 then '10' ElseIf
[YearsTenure]=15 then '15' ElseIf
[YearsTenure]=20 then '20' ElseIf
[YearsTenure]=25 then '25' ElseIf
[YearsTenure]=30 then '30'
else 'Non Milestone'
endif

Luke_C
17 - Castor

@dmitkevich If you're tracking every 5 years you could simplify to and just check if the number is evenly divisible by 5

 

IF Mod([YearsTenure], 5) = 0 then [YearsTenure]
else 'Non Milestone'
endif

 

dmitkevich
6 - Meteoroid

Thank you for the suggestion.   I tried it but it also generated "Malformed If Statement" Error.  What I am trying to do is to look at all the values in the column "YearsTenure" and if any of the values match 5/10/15/20/25/30 then return that value, otherwise mark it as "non milestone"

Luke_C
17 - Castor

*Edited*

 

Hi @dmitkevich, YearsTenure is being created as text, change it to be Double and it should work

Luke_C_1-1657826479376.png

 

 

Here's a workflow showing both suggestions in action. 

 

Luke_C_0-1657826356930.png

 

 

 

dmitkevich
6 - Meteoroid

Thank you, I think I finally got it to work :D

Luke_C
17 - Castor

@dmitkevich Great! Happy to help - be sure to tag the solution 😀

Labels