Alteryx Designer Discussions

Find answers, ask questions, and share expertise about Alteryx Designer.
ALTER.NEXT:

Join us on Dec 2 for a half-day virtual analytics + data science event!
US & CA customers only

SAVE YOUR SPOT
It's the most wonderful time of the year - Santalytics 2020 is here! This year, Santa's workshop needs the help of the Alteryx Community to help get back on track, so head over to the Group Hub for all the info to get started!
SOLVED

Appending an empty column IF said column does not exist

Highlighted
8 - Asteroid

Hello all, I have a problem with my data blending that involves a column which may or may not be there.

 

Let me explain:

 

1. This workflow is used by many people, of which different columns may exist.

2. However, one such workflow is unable to proceed without the existance of a column, which exists in the source file of some people who use the workflow, and some source files that dont.

3. To solve this problem, I would like alteryx to 'detect' and add a null column with the said column name if it does not exist.

 

Any idea how?

Assume that the previous tool was SELECT, and the eventual connection out is to a JOIN, but that's irrelevant to the solution in my opinion.

 

Thanks again!

 

Thanks.

Highlighted
Alteryx
Alteryx

Hi @elizabethmichaels91,

 

You can do this by adding a text input with that column and then a union that on to the data. 

 

There is other ways, one being the Ensure Fields Tool in the CReW Macro Pack, and another using a Field Info tool to get a list of the fields that exist and comparing against a list, but the text input is quick and solves the problem.

 

Note: To quickly get a text input with all the fields required, look at the browse on a sample of the data that has all the fields, highlight the first row, press the copy icon and 'Selected Cells with Headers', then right click on the canvas and paste, then you can just delete that row in the text input.

 

Kane

Highlighted
8 - Asteroid

Hi Kane, thanks for your reply.

 

I tried your solution but a join will not happen if the column did not exist in the first place.

 

I solved it using an append tool with a text input instead!

 

Thank you for your help!

Highlighted
Alteryx
Alteryx

Hi @elizabethmichaels91,

 

Using an append tool, you will get a duplicate column if the column already exists. As you said, you can't use a Join tool, but a Union tool will stack rather than joining and so you will just get the extra column if it doesn't exist.

 

Kane

Highlighted
Alteryx Partner

I am unable to paste just the header columns into the fields section of text input. This forces me to manually copy and paste each column name into fields.

Highlighted
Alteryx Partner

Please discard this. solved!

Highlighted
Inactive User
Not applicable

can you share how did you solve this?

Highlighted
Alteryx
Alteryx

When copying and pasting between Browse and text input, do not use Ctrl+C/V, instead use the buttons provided in the tool

 

Copy_paste_buttons.png

 

In the above solution though, I advised to copy the first row from the browse or results window and then just right click on the canvas and paste.

 

Copy_from_browse.png

 

Then pasting on a blank canvas will create a text input tool

Paste Text input.png

Highlighted
Alteryx Partner

Thanks a lot @KaneG. This is precisely the workaround i used. 

Highlighted
7 - Meteor

How can we do this using field info

Labels