Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

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

Reverse a String in a row

Shekharreddy125
7 - Meteor

Hello,

I have a data like below.

 

1.John David

2.Mock Refel

3.David Hats 

 

I want the out put in reverse string order like below

1.David John

2.Rafel Mock

....

...

 

I tried Text to columns and then combine but it looks lengthy.

 

Thanks in advance. 

7 REPLIES 7
ConnorK
Alteryx
Alteryx

Hi Shekharreddy125,

 

One thing that you could try is breaking the names apart with a text to columns tool, and then combining the two columns in the correct order with a formula tool.

 

Here is an example.

 

Connor Kelleher
Senior Sales Engineer
Alteryx
BenMoss
ACE Emeritus
ACE Emeritus
I would go with a regex function in a formula tool...

Regex_replace([field],"(\w+) (\w+)","$2 $1")

So take the first two parts and swap them round.

Ben
ConnorK
Alteryx
Alteryx

Apologies, I did not see your end note about the text to columns. You could also try parsing these items out with Regex in a formula tool, and then combining them back together within the same tool. However, I think the text to columns is a more simple approach.

Connor Kelleher
Senior Sales Engineer
Alteryx
TravisR
Alteryx Alumni (Retired)

@BenMoss got the regex solution I couldn't figure out - but here's a non-regex formula:

 

Left([Field], STRCSPN([Field],'.')+1) + GetWord([Field], 1) + ' ' + GetWord(Right([Field], Length([Field]) - STRCSPN([Field],'.')-1), 0)

Shekharreddy125
7 - Meteor

It's working. Thank you so much @BenMoss

Shekharreddy125
7 - Meteor

Thank you for your quick response.

nclassen
5 - Atom

Thanks Ben, I found this helpful as well!

Labels