How to get Alteryx to create a new row based on an IF condition, whilst keeping same data
- 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
Hi there,
I am looking to see if it is possible for Alteryx to create a new row of data based on an IF Condition.
I have provided a sample excel scenario below:
I would like to achieve a condition where if the column "CHANNEL" contains text "Candy, Phone" in a row, I would like it to create another row, keeping all other column values in the row constant, except it separates out "Candy" and "Phone".
Thanks,
Solved! Go to Solution.
- Labels:
- Tips and Tricks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @alianto this looks like you should just be able to handle that with the Text To Columns tool.
Just set your delimiter to a comma and select [CHANNEL] as the column to split, making sure 'Split to Rows' is selected.
Before:
After:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @DataNath
Thanks for the prompt response. I noticed based on your solution that given there were only two options (phone and candy) that the delimiter was a simple "," in your Text to Columns tool.
If I attempted to add a third option, I.E: Phone, Candy, Pencil, and wanted to split it up as "Phone, Candy" in one row and "Pencil" in another. How would I go about it as I am attempting to modify the Text to Columns tool to no success.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @DataNath
Thanks for the prompt response. I noticed based on your solution that given there were only two options (phone and candy) that the delimiter was a simple "," in your Text to Columns tool.
If I attempted to add a third option, I.E: Phone, Candy, Pencil, and wanted to split it up as "Phone, Candy" in one row and "Pencil" in another. How would I go about it as I am attempting to modify the Text to Columns tool to no success.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @alianto, what would the specific logic be in this case? If it needs to split at certain points then would need to know the rationale behind that as the solution would require a bit more work than a text-to-columns here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @DataNath,
The logic would be specific instances of Text in my "Channel" column, for example I would only need it to split into separate rows if it had "Phone, Candy, Pencil" or "Phone, Candy, Bread". If it said something like "Mic, Air", I would not need it to split.
Hopefully that clarifies things.
Thanks,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hey @alianto, if you only wanted to split based on the presence of certain key words, and split from that point on then I would propose something like this...
1) We check for a pattern match of <something>Candy,<something> - if this is found, replace "Candy," with a unique delimiter so it becomes "Candy|"
2) We then split to rows based on this new delimiter, leaving everything else untouched:
