Alteryx designer Discussions

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

Isolating first and last words in string

Highlighted
5 - Atom

Hi there,

 

I am trying to isolate the first and last word in a string. I have data of names and some names include middle names or nicknames The names can vary up to 5 words.... I first tried to do text to columns but then I don't know how to get the surname of the shorter names under the right column. I then tried to use the RegEx function to parse the first and last names but have been unsuccessful in writing a formula. Please can someone assist?

 

Thanks!

Highlighted
Alteryx
Alteryx

Hi @rwelman003 

 

If you use the Formula tool you can use the 'GetWord' and 'CountWords' formulas to get this for you.

 

For the first name it would be Getword([Field], 1) then for the last name it would be Getword([Field]. (Countwords([Field])-1)

 

Let me know if that works for you

 

Kind regards

Will

Highlighted
5 - Atom

Brilliant, this has worked perfectly! Thanks so much!

Highlighted
Alteryx Certified Partner

Hi @rwelman003 

 

Please see attached example of how this can be achieved using RegEx.

 

first_last.PNG

 

 

 

Regards,

Karam

Labels