Alteryx Designer Desktop Discussions

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

Parsing

Lucasvital
7 - Meteor

Hi,

 

I have a series of zip codes that I need to parse the first set (District only), but they can be 3 or 4 strings (all separated by a space) so the Left formula is not working effectively. Is there a way that the formula left will be able to identify which ones should be 3 and which ones should be 4? I assume Regex/parsing could do that.

 

Here are some examples:

Input

EC1A 2FD
L9T 5G3

B93 0HL

 

Output 

EC1A

L9T

B93

 

Thanks

4 REPLIES 4
fmvizcaino
17 - Castor
17 - Castor

Hi @Lucasvital ,

 

Since the delimiter is always a space, you can use the text to columns tool to achieve what you want.

I attached an example showing in Alteryx how to do it.

 

Let me know if that works for you.

Best,

Fernando Vizcaino

MarqueeCrew
20 - Arcturus
20 - Arcturus

You might want to use a text to columns tool!  Change the delimiter to \s and you'll get the result quickly. 

cheers,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
MarqueeCrew
20 - Arcturus
20 - Arcturus

Ps. 

regex_replace([postal code],"(.*)\s.*",'$1')

 

 that formula will do the parade for you. 

cheers again,

 

 mark

Alteryx ACE & Top Community Contributor

Chaos reigns within. Repent, reflect and restart. Order shall return.
Please Subscribe to my youTube channel.
DiganP
Alteryx Alumni (Retired)

@Lucasvital @You can also use getword() as well. 

 

GetWord(String, n): Returns the Nth (0-based) word in the String. Words are defined as a collection of characters separated by a space. 0-based index, means the first word is at the 0 position.

 

In your case, it would be getword([field1],0). This will grab the first digits till the space. 

Digan
Alteryx
Labels