Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Check if column exists and if not, create it with a formula

LinhNguyen
8 - Asteroid

Hi, 

 

Is there any way I can check a file to see if a column exists and if it's not there, create it with a formula. If it is in the data set then move on to the next part?

For example, I want a table with first name, last name and full name, if Full name is not in there (as in the below table), then create a column that concatenate first and last name:

IDFirstnameLastname
1JohnAdam
2MeganBrown
3JessieSitkoff

 

If the Full name is in the data set and there's not separated columns for first and last name, then do text to column or something to get the two columns firstname and last name.

 

Thank you!

4 REPLIES 4
BrandonB
Alteryx
Alteryx

I did something similar before with a text input and a union tool. You create a text input with the fields that you are checking for. Then union that with your file you are feeding in. After that you can use a formula tool that says:

 

In the formula we would select the "FullName" field

 

IIF(IsNull([FullName]),[FirstName]+" "+[LastName],[FullName])

 

What this will do is create a full name if the value is null and use what is in the FullName field if it already exists. Then you can use a filter tool where FullName is not null to get rid of the fields with null text input values that you unioned in. 

LinhNguyen
8 - Asteroid

Awesome! Thank you!!!

jmuetzel
6 - Meteoroid

Worked for me too!  Thanks!

sarah_salisbury
5 - Atom

This was so helpful. Thank you so much!

Labels