Alteryx Designer Desktop Discussions

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

Replace any field that contains the letter "d" with just the letter "d"

Ryan_Stocker
5 - Atom

I have a list of fields that may or may not contain the letter "d" or the letter "t". I need any instance where the field contains the letter "d" to replace it with "d" or any time it contains the letter "t" to replace it with "t" and if it doesn't contain either, to make the cell blank. The screenshot below shows a few examples of the original code and then the code I would like it to be. What formula could I write to accomplish this?

Original CodeNew Code
dd
s 
sdd
sr 
rtt
5 REPLIES 5
Clifford_Coon
11 - Bolide

Hi @Ryan_Stocker ,

 

Something like this:

formula.jpg

 

The formula is:  

 

IF Contains([Original Code], "d") THEN "d"
ELSEIF Contains([Original Code], "t") THEN "t"
ELSE null() ENDIF

 

nagakavyasri
12 - Quasar

Screenshot 2023-06-14 140605.png

BS_THE_ANALYST
14 - Magnetar

I'd approach it like this, it will check ALL columns by leveraging the transpose tool. Makes the workflow dynamic:

Before & After:

BS_THE_ANALYST_0-1686766688105.png

BS_THE_ANALYST_1-1686766700911.png

 

Formula:

BS_THE_ANALYST_2-1686766720603.png

 


As a final note, be careful of the contains formula, it is case insensitive by default, you can add an optional 3rd argument to change this though:

BS_THE_ANALYST_3-1686766799764.png

 

If you want to make the cell blank, edit the formula -> ELSE null().

If you want to only select certain columns, I'd just advice using the Multi-Field Formula tool. This allows you to use one formula across multiple fields. This satisfies your requirement. 



All the best,
BS

 

 

Ryan_Stocker
5 - Atom

Thank you everyone!

hlee36
8 - Asteroid

My approach with a formula.

 

hlee36_0-1686775809838.png

 

Labels