Join the Alteryx Community’s Maveryx Summer Cup event! Compete, network with others, and earn your gold through a series of challenges from July 24th to August 11th. Learn more about the event here.

Alteryx Designer Desktop Discussions

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

The if formula not work correctly.

Beckyli
8 - Asteroid

when I first time run the workflow, it works fine, but when I second time run it, pop out the error. my formula should be 

IF [JOURNAL]= "321" or [JOURNAL]= "331" or [JOURNAL]= "341" THEN "TURE" ELSE "FALSE" ENDIF

 

Beckyli_0-1661987635576.png

 

1 REPLY 1
DataNath
17 - Castor

Hey @Beckyli at the moment, you're likely getting that error as your [JOURNAL] field is numeric and by wrapping your checks in quotes i.e. "321", "331", you're looking for a string value. Therefore, you can either use a Select tool before your formula and make [JOURNAL] a string data type, or remove all of the quotes from your Formula tool expression to leave:

 

IF [JOURNAL]= 321 or [JOURNAL]= 331 or [JOURNAL]= 341 THEN "TRUE" ELSE "FALSE" ENDIF

 

Also, as a side note: You can clean up expressions like this by using the 'IN' function so that you don't have to type out X = or X = or X = multiple times. In your case this would be:

 

IF [JOURNAL] IN ("321","331","341") THEN "TRUE" ELSE "FALSE" ENDIF

 

Or if you keep [JOURNAL] numeric:

 

IF [JOURNAL] IN (321,331,341) THEN "TRUE" ELSE "FALSE" ENDIF

Labels