Appending an empty column IF said column does not exist
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
Solved! Go to Solution.
- Labels:
- Best Practices
- Interface Tools
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Please discard this. solved!
![](/skins/images/A7612391DEAF4EF69C140133EA533832/responsive_peak/images/icon_anonymous_message.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
can you share how did you solve this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
When copying and pasting between Browse and text input, do not use Ctrl+C/V, instead use the buttons provided in the tool
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.
Then pasting on a blank canvas will create a text input tool
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Thanks a lot @KaneG. This is precisely the workaround i used.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
How can we do this using field info
![](/skins/images/A7612391DEAF4EF69C140133EA533832/responsive_peak/images/icon_anonymous_message.png)