Alteryx Designer Desktop Discussions

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

Flip First and Last Names in a Column

I have a column in the format of Last Name First Name, eg Smith John. I want it to change to John Smith. Help please! 

7 REPLIES 7
atcodedog05
22 - Nova
22 - Nova

Hi @veronikababiciute 

 

Here is how you can do it.

 

Formula:

REGEX_Replace([Field1], "(.+)\s(.+)", "\2 \1")


Workflow:

atcodedog05_0-1628852884828.png

 

Hope this helps : )

 

HomesickSurfer
12 - Quasar

Hi @veronikababiciute 

 

Though not as clean as the Regex, here's my approach that allows for variations of Firstname and possible middlename

 

Capture.PNG

Worked, thank you so much! 

atcodedog05
22 - Nova
22 - Nova

Happy to help : ) @veronikababiciute 

Cheers and have a nice day!

Meenssankar
6 - Meteoroid

If I want include comma after reversing the string using regex_replace?

atcodedog05
22 - Nova
22 - Nova

Hi @Meenssankar 

 

The formula would be add comma between 2 and 1

 

REGEX_Replace([Field1], "(.+)\s(.+)", "$2 ,$1")

 

Hope this helps : )

trevorwightman
8 - Asteroid

I have never taken the time to learn regex so I just stick with string manipulation to get what I want. I just rebuilt the name by finding the space and taking what is to the right, then adding a space and then taking what is the left. Cheers!

trevorwightman_0-1633549863134.png

 

Labels