Length of a string, find last digits.
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
|
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?
Solved! Go to Solution.
- Labels:
- Custom Tools
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @wonka1234,
You could use a piece of regex logic to extract these numbers:
I've attached my workflow for you to download if needed!
Kind regards,
Jonathan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
thanks, this almost works, except for ACF2 - I need the numbers after the 2. 😞 may be hard to do..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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})$
Hope that helps,
Ollie
