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

Alteryx Designer Desktop Discussions

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

Truncate comma delimited string

neeleshapatil1
8 - Asteroid

What is the best/cleanest way you know of to take a comma delimited string, such as "A,B,C,D,E,F,G", and return only the 1st  5 amount of items in the list? So the result would be "A,B,C,D,E". 

 

I don't want to split first and perform this operation to increase record volume. Please let me know if there is any another way to perform this operation.

1 REPLY 1
TonyA
Alteryx Alumni (Retired)

I would probably just split the string and combine it unless you are dealing with extremely large data sets. My next choice would be using REGEX, which would probably be faster, but harder for many to understand. I'm no REGEX expert and I'm sure someone can come up with a more elegant example but the attached does what you want.

The pattern is just five instances of characters that don't include "," separated by commas:  "([^,]*,[^,]*,[^,]*,[^,]*,[^,]*).*" -> "$1"

Labels
Top Solution Authors