Hello everyone,
I'm trying to get the below SQL formula to work in the Alteryx Formula tool -
IF [Disposition Comment] CONTAINS "%medication%"
OR [Disposition Comment] CONTAINS "%meds%"
OR [Disposition Comment] CONTAINS "%Dr. Gould%"
OR [Disposition Comment] CONTAINS "%Dr. Zimmerman%"
OR [Disposition Comment] CONTAINS "%Psych%"
OR [Disposition Comment] CONTAINS "%doctor%"
OR [Disposition Comment] CONTAINS "%Lindsey G. PA%"
OR [Disposition Comment] CONTAINS "%med refill%"
AND [Program Name] CONTAINS "MH%"
THEN "Psych" ELSE "Not Psych" ENDIF
But I keep getting this "Malformed If Statement"
What am I doing wrong???
Solved! Go to Solution.
the syntax for the contains function is contains([field],"X")
Your syntax is off a little. Check out the examples for the Contains function:
https://help.alteryx.com/current/en/designer/functions/string-functions.html##
And delete the % characters inside each double quote.
You may also need some parenthesis around your OR and AND clauses.
Chris
Okay, these suggestions helped - Thank you! Updated to:
IIF(Contains([Disposition Comment], 'medication') OR
Contains([Disposition Comment],'meds') OR
Contains([Disposition Comment], 'Dr. Gould') OR
Contains([Disposition Comment], 'Dr. Zimmerman') OR
Contains([Disposition Comment], 'Psych') OR
Contains([Disposition Comment], 'doctor') OR
Contains([Disposition Comment], 'Lindsey G. PA') OR
Contains([Disposition Comment], 'med refill') AND
Contains([Program Name], 'MH')
THEN "Psych" ELSE "Not Psych" ENDIF
At the THEN I'm now getting a "Malformed If Statement" error. So, better...
You changed IF to IIF at the beginning - I would change it back. In addition, it looks like you may have an extra open parentheses at the beginning!
That worked!!!!!!!!!! THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU!
User | Count |
---|---|
19 | |
14 | |
13 | |
9 | |
8 |