Alteryx Designer Desktop Discussions

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

How to write a If statement

terrellchong
8 - Asteroid

My sets of data contains:-

ABC_DE_12345_678
ABC_12345_678
ABC
ABC_12345

 

I want to remove the end of the letter so that the column will become the following results

ABC_DE
ABC
ABC
ABC

 

How do i write a if statement say if its detect its a digit at the end of the row, it will automatically remove the digit with the underscore?

3 REPLIES 3
mceleavey
17 - Castor
17 - Castor

Hi @terrellchong ,

 

is there any reason you would want to use an IF statement?

 

I've attached a workflow which does this in Regex:

 

mceleavey_0-1625224343596.png

 

What this is doing is saying remove all numbers, and where this an underscore followed by a number, and a number followed by an underscore.

This will give you the results you need in this example.

 

Hope this helps, 

 

M.

 



Bulien

ArtApa
Alteryx
Alteryx

Hi @terrellchong - Almost everything in Alteryx can be done in a couple of different ways:

 

ArtApa_0-1625276686935.png

 

atcodedog05
22 - Nova
22 - Nova

Hi @terrellchong 

 

This is a great use-case for regex_replace. You can use a formula like below to replace underscore(_), followed by numbers(\d) and any characters(.*) to blank.

REGEX_Replace([Input], "_\d.*", "")

 

Workflow:

atcodedog05_0-1625296029778.png

 

Hope this helps 🙂

Labels