Alteryx Designer Desktop Discussions

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

Contains/Find and Replace part of the results with IF statement

Sam7
8 - Asteroid

Hello, 

 

I am have one column contains various numbers and letters. 

 

Column A: 

ARS_00100000
ARS_00002099
ARS_00600000
ARS_011-00000
ARS_01500000
EIS_02000000
EIS_021-00000
EIS_000000
EIS_00250-0000
EIS_0002600000
EIS_03500000
AAS_036-000-00
AAS_04000000

 

I want to update Column A based on this logic: 

  • find and replace function “-“ to nothing
  • find and replace function “_00000“ to “_”
  • find and replace function “_0000“ to “_”
  • find and replace function “_000“ to “_”
  • find and replace function “_00“ to “_”
  • find and replace function “_0“ to “_”

I wrote:

 

IF Contains([Column A],'-') THEN REGEX_Replace([Column A], '-', '')
ELSEIF Contains([Column A],'_00000') THEN REGEX_Replace([Column A], '_00000', '_')
ELSEIF Contains([Column A],'_0000') THEN REGEX_Replace([Column A], '_0000', '_')
ELSEIF Contains([Column A],'_000') THEN REGEX_Replace([Column A], '_000', '_')
ELSEIF Contains([Column A],'_00') THEN REGEX_Replace([Column A], '_00', '_')
ELSEIF Contains([Column A,'_0') THEN REGEX_Replace([Column A], '_0', '_')
ELSE [Column A]
ENDIF

 

 

This did not work, I then wrote the same code with FindString and Replace but this didn't work either. 

 

What am I doing wrong?  Thanks for your help

 

2 REPLIES 2
BrandonB
Alteryx
Alteryx

It looks like maybe you have some extra quotations in your formula

 

ELSEIF Contains([ColoumA],'“_00000') THEN REGEX_Replace([ColoumA], '“_00000', '_')

 

You have extra quotes before the _00000 as well as in your second instance down at the end. You also have column spelled Coloum, not sure if that is the issue. What is the error message that you are seeing?

Sam7
8 - Asteroid

Corrected that, working while home schooling!🙄

 

Please can you help with the code.  I am not sure how to create a if statement based on the condition and rule

Labels