Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

New field creation based on the text in a free text field

Pranee_007
7 - Meteor

I have a free text field (Say 'Comment') which contains lot of information. I want to create a new field based on 3 conditions.

 

1. If the field 'comment' contains value 'Pay', I want the new field to be created with pay and following 10 letters.

2. If the field contains 'nopay' or 'donotpay', I want the field to be updated with nopay and donotpay respectively.

3. If the above three keywords are not found, I want the new field to be updated with 'check'.

 

Example:

CommentNew field output
Transaction 4584838790 pay3546779890 Coded 758u498pay3546779890
Large item 4584838790 nopay Name 758u498nopay
Small item 45848387976 donotpay Mandy 758u498donotpay
Medium size carrot gold finger 86482928749check
5 REPLIES 5
Dazzerman
11 - Bolide

Hi @Pranee_007 ,

 

Try this workflow.

 

You can modify the regex if you definitely only need it to capture 10 digits after the 'pay' text, but I set it to capture anything between 5 and 10 digits.

 

Hope this helps.

afv2688
16 - Nebula
16 - Nebula

Hello @Pranee_007 ,

 

A formula tool with the following worked for me:

 

IF Contains([Comment], 'donotpay') THEN 'donotpay'
ELSEIF Contains([Comment], 'nopay') THEN 'nopay'
ELSEIF Contains([Comment], ' pay') THEN REGEX_Replace([Comment], '(.*)(\s)(pay)(.{10})(.*)', '$3$4')
ELSE 'check'
ENDIF

 

Regards

Pranee_007
7 - Meteor

Hi Dazzerman,

 

The solution you provided works well. But, how to make it case insensitive?

 

Even if someone provides comment as NoPay, how will it recognize?

afv2688
16 - Nebula
16 - Nebula

Hello @Pranee_007 ,

 

The solution for that would be to edit the comment to be lowercase first

 

Untitled2.png

 

Regards

Dazzerman
11 - Bolide

Hi @Pranee_007 ,

 

You can toggle the case sensitivity in the config for the Regex Tool here :

 

Regex_config.jpg

Labels