Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.
Free Trial

Alteryx Designer Desktop Discussions

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

Split a string with an uncertain length into 2 characters per column

vvcunha
5 - Atom

Dear Alteryx Community
I am trying to split a string (the string length is uncertain; it could be 10 characters or 100 characters) into multiple columns, and each column should only contain 2 characters.

 

For example,

vvcunha_0-1675937977198.png

 

I am not sure how to do it, tried to use regular expression to parses the data with a fix number of characters and grouping like (..)(..) but it didn't work as I could cater for both short and long string lengths. 

5 REPLIES 5
DataNath
17 - Castor
17 - Castor

Hey @vvcunha, here's one way you could handle this:

 

DataNath_0-1675938850272.png

DataNath_1-1675938857591.png

 

The key here is to use the RegEx tool in tokenize, .{2} splits every 2 characters onto a new row:

 

DataNath_2-1675938889325.png

 

From there, we just use the Multi-Row Formula to assign a RecordID (grouped by the original Record it came from), ready for Cross-Tabbing back into the desired form:

 

DataNath_3-1675938933434.png

 

Hope this helps!

ShankerV
17 - Castor

@vvcunha 

 

One way of doing this.

 

ShankerV_0-1675939101244.png

 

Input was:

ShankerV_0-1675939134119.png

 

 

vvcunha
5 - Atom

@DataNath @ShankerV
Thank youfor your solutions. They both worked  well  and did the job of spliting the the string the way I wanted to. 
I didn't expect Alteryx wouldn't haldeled creating 50rows for it data entry since I had over 20,0000 entries. I'm very surprised how it handled well. 

One following up questions. In the final outcome the orginial Column disappeared and I couldn't figure  out in wich steps of the flow I could add it back on. 

 

Thanks. 

ShankerV
17 - Castor

Hi @vvcunha 

 

The Record ID tool which we already used in the workflow helps to bring back the original field to the dataset.

 

Hence used the join tool to add the Original Column for reference.

 

Please let me know if you have more questions.;

 

ShankerV_0-1676013212190.png

 

Many thanks

Shanker V

DataNath
17 - Castor
17 - Castor

Hey @vvcunha, glad to hear it worked well! As we've already sorted into the original order after the Cross-Tab, we can just conduct a join on the record position. The Join tool has built-in Select functionality and so we can remove the RecordID column and move fields around as needed to clean things back up as well:

 

DataNath_0-1676019746091.png

Labels
Top Solution Authors