Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.
Free Trial

Alteryx Designer Desktop Discussions

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

Reference part of number

skeen503979
8 - Asteroid

Hello, 

 

This is a bit of an odd request, but here goes.  I have a reference file that shows the first PART of a serial number.  My data set contains the full serial number.  How can I link the two so that I'm able to pull in additional data from the reference file base on those first few numbers of the serial number?  In the example below I am trying to create a column showing the color.

I hope that makes sense.

Thank you!

 

 

Example:

 

Serial number

111111188888 - (result of workflow should say "Red")

111111280461 - (result of workflow should say "Blue")

111111375486 - (result of workflow should say "Yellow")

 

 

Serial number beginning Characteristic
1111111Red
1111112Blue
1111113Yellow

 

6 REPLIES 6
clmc9601
13 - Pulsar
13 - Pulsar

Hi @skeen503979,

 

One way for this use case specifically is to use the Find Replace tool. It has a configuration that allows you to look at the beginning of the fields. I used Select tools in this picture because Find Replace only works on strings, not numbers.

 

Other use cases might require extracting the first X characters of the serial, like with the Left() function or regex.

 

clmc9601_0-1628114939023.png

I hope this helps!

 

clmc9601
13 - Pulsar
13 - Pulsar

Here's the workflow if that's easier.

apathetichell
19 - Altair

switch(right(left(tostring([field1]),7),1),"red","1","red","2","blue","3","yellow")

 

in formula tool will do this for you. assuming the first 7 are what you want.

atcodedog05
22 - Nova
22 - Nova

Hi @skeen503979 

 

Just adding another method to above methods. Using formula startswith.

 

IF StartsWith([Serials], "1111111") THEN "Red" 
ELSEIF StartsWith([Serials], "1111112") THEN "Blue" 
ELSEIF StartsWith([Serials], "1111113") THEN "Yellow" 
ELSE Null() ENDIF

 

Workflow:

atcodedog05_0-1628141543308.png

 

Hope this helps : )

 

skeen503979
8 - Asteroid

Thank you @atcodedog05 , @apathetichell , @clmc9601!  Those were all very helpful.  I really appreciate the community. 👍

atcodedog05
22 - Nova
22 - Nova

Happy to help : ) @skeen503979 I like your profile pic it looks like R2D2

Cheers and have a nice day!

Labels
Top Solution Authors