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,
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.
Hey @vvcunha, here's one way you could handle this:
The key here is to use the RegEx tool in tokenize, .{2} splits every 2 characters onto a new row:
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:
Hope this helps!
@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.
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.;
Many thanks
Shanker V
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:
User | Count |
---|---|
18 | |
14 | |
13 | |
9 | |
8 |