Alteryx Designer Desktop Discussions

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

Length of a string, find last digits.

wonka1234
10 - Fireball

Hi all,

 

Trying to replicate this pyhton logic in alteryx, however I am having trouble understanding what it does.

 

df1['ColA'] = [ID[Length:] for ID, Length in zip(df1.ID, df1.Length)]

 

Length column counts the length of each string in another (unshown) column:

5
5
4
7

 

 

ID sample records:

CMREV2824
HRTAO3139
ACF22353
ADTDBFG102

 

corresponding ColA:

2824
3139
2353
102

 

To me it looks like take the last digits based on the length of the "Length" column.

 

Does anyone know how I can replicate this functionality in a alteryx formula?

4 REPLIES 4
Jonathan-Sherman
15 - Aurora
15 - Aurora

Hi @wonka1234,

 

You could use a piece of regex logic to extract these numbers:

 

JonathanSherman_0-1639333532918.png

 

 

I've attached my workflow for you to download if needed!

 

Kind regards,

Jonathan

wonka1234
10 - Fireball

thanks, this almost works, except for ACF2 -  I need the numbers after the 2. 😞 may be hard to do..

apathetichell
19 - Altair

I think there was some confusion about what you want because everything you chose was a number - assuming you want a the remainder of the string starting at the character in the second column - you'd use:

 

Substring([Field1],[Field2],length([Field1])-[Field2])

 

where [field1] is your string and [field2] is your starting character.

OllieClarke
15 - Aurora
15 - Aurora

Hey @wonka1234 

This regex (tweaking @Jonathan-Sherman's slightly) will take the last digits up to 4 from ID (in Parse Mode)

 

(\d{1,4})$

 

OllieClarke_0-1639394793972.png

Hope that helps,

 

Ollie

 

Labels
Top Solution Authors