Bring your best ideas to the AI Use Case Contest! Enter to win 40 hours of expert engineering support and bring your vision to life using the powerful combination of Alteryx + AI. Learn more now, or go straight to the submission form.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Create new column based on conditions from previous column's information

jfisherdk
5 - Atom

Hi all! I am new to alteryx and needing some help with creating a new column which relies on a current column's info. 

 

For reference this is redacted data I am using - the new column I need to create is Region which uses the info in Department:

DepartmentRegion (NEW Column)
ABC (US)US
DEF (US)US
GHI (Asia)Asia

 

So far, I have tried using the formula tool with the following expression:

Region = If [Department] = 'ABC (US)' then 'US' else 'US' endif

Region = If [Department] = 'DEF (US)' then 'US' else 'US' endif

Region = If [Department] = 'GHI (Asia)' then 'Asia' else 'Asia' endif

 

However, in the Browse tool my results in the Region column only state 'Asia'. Can someone advise how to get around this problem? I have a similar data set that I need to do this on as well which has more variables.

 

Thank you!

4 REPLIES 4
alexnajm
18 - Pollux
18 - Pollux

For the part after ELSE, you should just reference [Region] instead of a hardcoded value since you just want to keep the value if it doesn’t match your condition

alexnajm
18 - Pollux
18 - Pollux

Region = If [Department] = 'ABC (US)' then 'US' else [Region] endif

Region = If [Department] = 'DEF (US)' then 'US' else [Region] endif

Region = If [Department] = 'GHI (Asia)' then 'Asia' else [Region] endif

 

there are more efficient ways to do this but this should at least be the easiest fix to your problem!

jfisherdk
5 - Atom

Thank you! When I put in the new expression I received an error for expression #1 (attached image). Do you know how I can avoid this? 

 
 

 

alexnajm
18 - Pollux
18 - Pollux

I didn't realize you didn't have Region as a field before - in that case your first formula will be f [Department] = 'ABC (US)' then 'US' else Null() endif

Labels
Top Solution Authors