Start Free Trial

Alteryx Designer Desktop Discussions

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

Using If/Then with Replace in Formula Tool

dngnc7
7 - Meteor

I have a workflow where I need to change the current name in a field to another name if the condition is met. I have the formula set up, but when I run my workflow, it does not replace the old name with the new. Any ideas on what I am doing wrong? This is not the real scenario, just an example.

 

dngnc7_1-1750359795025.png

 

 

3 REPLIES 3
abacon
13 - Pulsar

@dngnc7 Without the dataset and workflow itself, it is hard to say.

 

I would look at the datatypes of the columns you have included. Is ColumnA not a string type but you are looking for a string, if so you would just need to throw a ToString() in front of ColumnA within the formula and it would work.

Again, hard to really diagnose without seeing the workflow and error itself.

 

EDIT: I realize these probably aren't real columns which is why the screenshot shows an error, @alexnajm's solution is definitely on the right track.

 

Bacon

alexnajm
18 - Pollux
18 - Pollux

This is correctly constructed syntax-wise although odd because it won't do anything - this tells me if the value in column a equals “dog”, then replace any instance of “animal” with “pet”, otherwise leave it alone. It is not going to do anything since you’re asking it to look for a “dog”, but you want to replace “animal”.

 

can you provide proof of your formula not working? Maybe this is what you want, to replace "Dog" with "Pet"?

IF [ColumnA]="Dog" THEN Replace([ColumnA], "Dog", "Pet") ELSE [ColumnA] ENDIF

caltang
17 - Castor
17 - Castor

Maybe you don’t have have Dog as a stand alone. You need CONTAINS([ColumnA],”Dog”) then continue your IF statement rather than [ColumnA] = “Dog”. 

Also, case sensitive! You can either use UpperCase(), LowerCase(), or TitleCase() to standardize.

Calvin Tang
Alteryx ACE
https://www.linkedin.com/in/calvintangkw/
Labels
Top Solution Authors