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

Alteryx Designer Desktop Discussions

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

Regex to get a part of the string based on a condition

cterrence
8 - Asteroid
 

Hi 

Please help

I need to get a  string based on a condition of another column. I tried using a formula didnt work

 

DescriptionTransaction Type
DEPOSIT CASH $3038.10 CHEQUE $0.00 Branch EATON 6101Cash Deposit
DEPOSIT CASH $664.20 CHEQUE $0.00 Branch DELORAINE 32701Cash Deposit
DEPOSIT CASH $1168.55 CHEQUE $0.00 QuickCash BUSSELTON 37901Cash Deposit

 

If the transaction type = Cash Deposit then please then from the Description column give me the string before the last number
essentially I should get
EATON

DELORAINE

BUSSELTON 

etc

7 REPLIES 7
BS_THE_ANALYST
14 - Magnetar
14 - Magnetar

@cterrence one way..

 

All the best,
BS

LinkedIN

Bulien
cterrence
8 - Asteroid

Thanks BS_THE_ANALYST - it worked however I just noticed that there could be two words between BRANCH or QUICKCASH . This happened to "ROCK CITY", it just threw CITY

Could you please assist

Regards

CT

caltang
17 - Castor
17 - Castor

Hi @cterrence 

 

Try regex with this:

(?i)(?:Branch\s+|QuickCash\s+)(\S+)

Screenshot 2023-07-09 195254.png

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
cterrence
8 - Asteroid

Thank you  @caltang - 

DescriptionTransaction Type
DEPOSIT CASH $3038.10 CHEQUE $0.00 Branch Rock City 6101Cash Deposit

 

It worked for some....however when there are two words as the example above...it throws up only Rock. It should come as ROCK CITY

 

Thanks

CT

caltang
17 - Castor
17 - Castor

@cterrence Very well, I've made it even more dynamic:

 

(?i)(?:Branch|QuickCash)\s+([A-Za-z\s]+)\s+\d+

Screenshot 2023-07-09 201214.png

 

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
caltang
17 - Castor
17 - Castor

@cterrence if it helps, kindly mark my comment as the accepted solution so that others may find it more easily.

 

Thanks!

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
flying008
15 - Aurora

Hi, @cterrence 

 

Another way for you want:

 

 

(?:Branch\s|QuickCash\s)(\D+?)(?=\s\d+$)

 

 

 

 

Labels