Alteryx Designer Desktop Discussions

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

Compare two Columns for string to extract matched value and put it in 3rd column

ahsansalik
8 - Asteroid

I have data in two columns i want to take value from Column 1 and then compare with Column 2 and extract the string plus 2 additional digits next to it and put them in column 3. the data in column 2 is manually entered so the placement of the string to be extracted could be different

 

Column1Column2column3
BANK BO06Ahsan has BANK BO06😄 0048030 NSWBANK BO06:D
HETH HA10Personal A HAS DEG HETH HA10:A 00020203032 CLARINDA VIC 3169HETH HA10:A
UNLY UL21Sonia has PO-U 0015 UNLY UL21-1 deposit 44454664645 Mitcham, SAUNLY UL21-1
7 REPLIES 7
Luke_C
17 - Castor

Hi @ahsansalik 

 

Here's a solution using the string functions. The orange piece finds the starting location of column 1 in column 2. It is wrapped in a substring function that returns the the piece of column 2 starting with the value returned by the findstring function, extending to the length of column 1 + 2.

 

substring([Column2],findstring([Column2],[Column1]),length([Column1])+2)

 

Luke_C_0-1622037713881.png

 

atcodedog05
22 - Nova
22 - Nova

Hi @ahsansalik 

 

Here is a regex approach.

atcodedog05_0-1622037950368.png

 

REGEX_Replace([Column2], ".*("+[Column1]+".{2})\s.*", "$1")

 

Hope this helps 🙂

 

ahsansalik
8 - Asteroid

Thanks for your help i am getting this error

 

ahsansalik_0-1622038985454.png

 

Luke_C
17 - Castor

Name the field in the formula tool

 

Luke_C_0-1622039050995.png

 

atcodedog05
22 - Nova
22 - Nova

Hi @ahsansalik 

 

You might not set column name in formula tool.

atcodedog05_0-1622039088622.png

 

 

ahsansalik
8 - Asteroid

ahsansalik_1-1622039126624.png

 

This Error Pops up once i apply the formula to my actual data with the original column names 

ahsansalik_0-1622039126591.png

 

ahsansalik
8 - Asteroid

Thanks a lot guys i am grateful for the help yayyy solved my first day at alteryx and i just learned a few good things 😄

Labels