Alteryx Designer Desktop Discussions

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

Formula: Error

MosesAddai24
7 - Meteor

I'm trying to input this code to generate state initials but I'm getting errors with my if statements. I thought it had to end with endif?Please can someone help me out?

6 REPLIES 6
KarolinaRoza
11 - Bolide

Hi @MosesAddai24 

 

I would suggest to apply tool 'Find Replace' for your case. I will really simplify your long formula.

Do you need help with applying this tool?

 

Karolina

 

JagdeeshN
12 - Quasar
12 - Quasar

Hi @MosesAddai24 ,

 

I think the issue is with your else clauses. Only the last clause should be an else, with everything else being an else if clause.

 

Please check the sample formula below:-

 

if contains([Header(State)],"HAWAII" )

then "HI"

elseif contains ([Header(State)],"ALASKA" )

then "AK"

elseif contains ([Header(State)],"ALABAMA" )

then "AL"

else "Default"

endif

 

Also attached is a sample workflow for your reference.

 

Do let me know if this resolves the error.

 

Best,

Jagdeesh Narayanan

MosesAddai24
7 - Meteor

I changed the else statements but it's still not working.

MosesAddai24
7 - Meteor

Thanks! I was able to use the find and replace tool in the data source

apathetichell
18 - Pollux

fyi- your original if/then/else/endif grouping had an error at character 27 - you didn't post the first screen shot of the beginning of your formula which is where there error would have been - but I  expect that you didn't close a "]" or are missing a comma or a ")" somewhere...

MosesAddai24
7 - Meteor

Yh i reviewed the font and it appears that the alteryx could not recognize my commas because they were smart quotes. It works now. Thanks!

Labels