This site uses different types of cookies, including analytics and functional cookies (its own and from other sites). To change your cookie settings or find out more, click here. If you continue browsing our website, you accept these cookies.
General Discussions has some can't miss conversations going on right now! From conversations about automation to sharing your favorite Alteryx memes, there's something for everyone. Make it part of your community routine!
Hi Community!
Looking to extract certain text out of a string value with the formula tool, I'm thinking RegEx, to create two fields
Current State:
USA 10 041 South Central
Desired State:
New Field 1 = 10
New Field 2 = 041 South Central
Any help would be great.
Thanks in advance!
Solved! Go to Solution.
Hi @dlopez
As well as Messi07's solution, you could also use Text-to-Columns with a space (or \s) as the delimiter and Number of columns = 3.
Thanks for the tips, would it be possible to do this with a formula in the formula tool?
Cheers
I'm curious why the Formula tool? It can be done with Regex, substring, substring with find. Lot's of options. To me, though, the Text To Columns is the simplest and most straightforward way given the example data you provided. And would be the simplest to document, maintain, and understand.
Yah completely agree, not denying all those tools can do it, they certainly can. I typically don't like to add more tools to my flow than necessary, I try to keep it as lean/simple as possible, I already have a formula tool in my flow which is why I'm looking for a solution in that tool specifically; and I just utilized a substring() function to do this.
Cheers
@dlopez ,
I'm piggy-backing on @PhilipMannering :
Expression #1: [FIELD 1]
Getword([Field],1)
Expression #2: [FIELD 2]
Substring([field],length(GetWord([Field], 0)) + length([Field 1]) + 2)
Cheers,
Mark
@PhilipMannering & @MarqueeCrew
Thanks for the solutions, always enjoy learning new ways of doing things. Below you'll see my solution I came to....
Current Field = USA 10 041 South Central - all records have "USA" before the bits I need
Calc Field 1 = Trim([Current Field], "USA") - produces "10 041 South Central"
Calc Field 2 = Left([Calc Field 1], 3) - produces "10"
Calc Field 3 = Substring([Calc Field 1],4) - produces "041 South Central"
I also have a SELECT tool in my flow, so I just drop calc field 1 there and leave calc field 2 & 3. This allows me to not have to add any new tools, already have a SELECT in my flow to rename fields, and keep the flow slim and trim.
Again thanks for your feedback on this, the GETWORD() func is a new one to me that I'll have to play with.
Cheers