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

Alteryx Connect Discussions

Find answers, ask questions, and share expertise about Alteryx Connect.
SOLVED

How to get Alteryx to create a new row based on an IF condition, whilst keeping same data

alianto
5 - Atom

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".

 

alianto_2-1668787442356.png

 

 

Thanks,

 

 

6 REPLIES 6
DataNath
17 - Castor
17 - Castor

Hey @alianto this looks like you should just be able to handle that with the Text To Columns tool.

 

DataNath_0-1668787670554.png

 

Just set your delimiter to a comma and select [CHANNEL] as the column to split, making sure 'Split to Rows' is selected.

 

Before:

DataNath_0-1668787978993.png

 

After:

DataNath_1-1668787989248.png

alianto
5 - Atom

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,

 

alianto
5 - Atom

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,

DataNath
17 - Castor
17 - Castor

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.

alianto
5 - Atom

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,

DataNath
17 - Castor
17 - Castor

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|"

 

DataNath_0-1668850148338.png

DataNath_1-1668850159270.png

 

2) We then split to rows based on this new delimiter, leaving everything else untouched:

 

DataNath_2-1668850189705.png