Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

create a new column if not exists in the input file

AKPWZ
8 - Asteroid

Hi everyone, 

I want to check a field, let's say "Age," to see if it already exists in the input file/select tool, and if not, I want to create a new field/column with the same name and add "0" or "Null" to it.

Can someone please help on this. Thank you!

 

Note:

Sometimes the required column is missing from the input data, so I want to create it only when it's not present, and then add either "0" or "Null" as the default value.

4 REPLIES 4
PhilipMannering
16 - Nebula
16 - Nebula

You could Union your data with a Text Input that has Age as a column. If the column does not exist it will be created, otherwise the Age will remain the same. See example attached,

PhilipMannering_0-1681117210057.png

 

AKPWZ
8 - Asteroid

HI @PhilipMannering thank you for the very quick response.
just wanted to add/ask one thing, that sometimes the required column is missing from the input data, so I want to create it only when it's not present, and then add either "0" or "Null" as the default value.
So in this conditions also your solution will work?

PhilipMannering
16 - Nebula
16 - Nebula

It should, yes. Try adding Age to the Text Input and testing it yourself!

NikiJF
7 - Meteor

@PhilipMannering Love this!! Such a simple solution - thank you for sharing it, it gave me a quick win this morning :-)

Labels