Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Community is experiencing an influx of spam. As we work toward a solution, please use the 'Notify Moderator' option on the ellipsis menu to flag inappropriate posts.
Free Trial

Alteryx Designer Desktop Discussions

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

Vlookup multiple strings

lmanda
6 - Meteoroid

Hi trying to obtain the following:

 

Search for both strings from Field1 (AB and 12345.0) in Field2 and return Field3

 

Field1
AB 12345.0

 

Field2Field3
CD blah blah blahA
AB blah blah-12345.0B

 

Desired output:

Field1Field3 
AB 12345.0B

 

 

Previously in excel I would do something using wildcards like:

VLOOKUP("*"&"AB"&"*"&"12345.0"&"*",'Sheet1'!B2:F100,5,FALSE)

 

not sure how to achieve the same in alteryx though...any suggestions appreciated, thanks!

 

5 REPLIES 5
Elias_Nordlinder
11 - Bolide

Hello @lmanda,

 

You can perform similar function as the Vlookup in Excel in Alteryx with a combination

of a Formula Tool (RegEx_Replace) and a Join Tool.
This assumes the pattern that you used for the Vlookup function.

 

I have attached a workflow and the picture below:

 

Elias_Nordlinder_0-1628655054527.png

Elias_Nordlinder_2-1628655252703.png

 

Elias_Nordlinder_1-1628655239172.png

 

 

1. Regex_Replace -> Looks for a specific pattern, in this case any one word

first, then anything after the hyphen.

2. Joins this new field with field 1

3. Only keeps field 1 and field 3 as you specified in your formulation.

 

Let me know if this answer your question or if you would need any more/more general workflow 🙂

 

//Regards

Elias

 

atcodedog05
22 - Nova
22 - Nova

Hi @lmanda 

 

Here is an exact replica of your vlookup.

 

Workflow:

atcodedog05_0-1628662843944.png

 

1. Using regex to match the exact pattern and create lookup value

2. Using find and replace to do vlookup. https://community.alteryx.com/t5/Interactive-Lessons/VLookUps-with-Designer/ta-p/80201 

 

Hope this helps : )

 

lmanda
6 - Meteoroid

Hi

@atcodedog05and @Elias_Nordlinder 

 

thank you for your responses, however apologies I'm still unable to get the desired output for my data.

Let me try to illustrate my initial problem better:

 

Co. will always appear first in line description, but agreement can be anywhere and there is no consistent position/pattern for that.

I want to search for if line description begins with Co. AND contains agreement anywhere in it, then return Co., agreement, and account

 

Dataset 1

Co.agreement
AB12345.0
CD12345.0

 

Dataset 2

Line description
Account
AB blah blah12345.0B
CD blah 12345.0- blahC

 

Desired output:

Co.AgreementAccount
AB12345.0

B

CD12345.0

C

 

 

thank you!

 

 

 

 

 

 

 

 

 

Elias_Nordlinder
11 - Bolide

Hello @lmanda ,

 

Okay, that changes it a little bit.

 

You can change your RegEx to something like this instead.

Elias_Nordlinder_0-1628767885475.png

 

1. Change first part to [A-Z]{2}

-> Any two Capital letters, as we cannot be specific on which letters

 

Elias_Nordlinder_0-1628767570843.png

 

2. Then create a Combination field of the two string of the first dataset.

-> As we want to see if the combination "AB 12345" etc. matches, not AB or 12345 separate.

 

Elias_Nordlinder_1-1628767622491.png

 

 

3. Then use the Find Replace tool on the Combo field and Lookup Field.

Elias_Nordlinder_2-1628767741298.png

 

 

4. Finally, use a select tool to only keep wanted columns in the end.

Elias_Nordlinder_3-1628767763892.png

 

I used @atcodedog05 method with Find Replace instead of the join method I used earlier as this better replicates vlookup in Excel like he mentioned in his comment 🙂 

 

//Regards
Elias

 

lmanda
6 - Meteoroid

@Elias_NordlinderThank you so much! I was able to achieve the outcome I need after some small tweaks to the Regex formula,

 

Here is the tweak in case anyone else needs it:

Regex_Replace([Field2], "([\w]{2})*.*([\d]{8}.\d).*","$1 $2")

 

([\w]{2}) <-- for any 2 characters

([\d]{8}.\d) <-- for any 8 digit number rounded to 1 decimal

 

Thank you so much again, really appreciate it!!

 

Labels
Top Solution Authors