We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

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

Replace formula for multiple replaces

RajatRehria
8 - Asteroid

Hi team, I want to know if there is any solution for multiple values using ‘AND’ , ‘OR’.

 

Example: Replace([Field], ‘ABC’, ‘XYZ’) this formula will replace ABC with XYZ and suppose I use Replace([Field], ‘EDF’, ‘UVW’) and this will replace EDF with UVW I just want to know if there is any way to use single Replace formula to replace ABC with XYZ and EDF with UVW, like we use “OR” , “AND” in “IF” formula

4 REPLIES 4
gautiergodard
13 - Pulsar

hey @RajatRehria 

Believe this should do the trick:

Replace(Replace([Field], ‘ABC’, ‘XYZ’), ‘EDF’, ‘UVW’)

 If your replacement values are static, you could also consider using the Find and Replace tool.

Felipe_Ribeir0
16 - Nebula

Hi @RajatRehria 

 

You can use the find replace tool to do this more easily. This tool is perfect to use in situations like this one. Check the attached workflow

 

Input:

 

Felipe_Ribeir0_0-1668185610115.png

 

 

Output:

Felipe_Ribeir0_2-1668185648490.png

 

 

DataNath
17 - Castor
17 - Castor

Hey @RajatRehria you can do this with a simple, single formula using the Switch function:

 

DataNath_0-1668185600011.png

 

Switch([Input],[Input],'ABC','XYZ','EDF','UDW')

 

To illustrate what's happening here, as the function is often a little confusing to understand just from the hover description:

 

Switch([Input],[Input],'ABC','XYZ','EDF','UDW') - The field the statement will act upon

Switch([Input],[Input],'ABC','XYZ','EDF','UDW') - The default value to put there if no possibilities from the list are found (kind of the equivalent to 'else' in an if statement)

Switch([Input],[Input],'ABC','XYZ','EDF','UDW') - Switch 'ABC' with 'XYZ' i.e. Case1/Result1

Switch([Input],[Input],'ABC','XYZ','EDF','UDW') - Switch 'EDF' with 'UDW' i.e. Case2/Result2

 

I've only used 2 examples in the list as per your ask above. However, to add more checks/replacements, you just continue to add comma-separated values in the form of 'Target','Replacement' (Case/Result according to the hover description).

Felipe_Ribeir0
16 - Nebula

Hi @RajatRehria 

 

It worked? 

Labels
Top Solution Authors