Important Community update: The process for changing your account details was updated on June 25th. Learn how this impacts your Community experience and the actions we suggest you take to secure your account here.

Alteryx Designer Desktop Discussions

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

Getting the right syntax for Replace function

mshinn9999
7 - Meteor

Hello all.  Again, I am still very new to Alteryx Designer. I do have a use case where for a given column, I need to replace all instances where the value starts with "F" and replace with this text:  "Taking everything into account, what can we do better?".

 

Example:  F32 is replaced with "Taking everything into account, what can we do better?"  

 

Please see screenshot.  I know it's a basic question. But, I cannot seem to get the syntax right.  I am assuming we also need the Startswith function.

 

Mike

 

 

 

 
 

 

7 REPLIES 7
Bren_Spill
12 - Quasar

Hi @mshinn9999 - try this: if StartsWith([Interview Question], "F") then Replace([Interview Question], [Interview Question], "Taking everything into account, what can we do better?") else [Interview Question] endif

iracine
7 - Meteor

Hello @mshinn9999  you can also achieve this by using a regex tool (one of my favorite) 

I've attached an image with the configuration but you just add the pattern and the replacement text.

In my opinion it's more explicit and easier to maintain. 

 

Capture d’écran 2024-05-25 à 12.37.10 PM.png

Have a fantastic day! 

mshinn9999
7 - Meteor

Amazing! I love this community!  Thank you for quick turn-around.

Yoshiro_Fujimori
15 - Aurora

@mshinn9999 ,

 

Similar to @Bren_Spill 's solution, this expression in Formula Tool would also work:

Interview Question =

IF StartsWith([Interview Question], "F")
THEN "Taking everything into account, what can we do better?"
ELSE [Interview Question]
ENDIF

fesrimo
8 - Asteroid

if StartsWith([Interview Question], "F")

then Replace([Interview Question], [Interview Question], "Taking everything into account, what can we do better?")

else [Interview Question]

endif

nzp1
7 - Meteor

You could use REGEX_REPLACE("F\d\d", "Taking everything into account, what can we do better?")

mshinn9999
7 - Meteor

Thank you all for the quick responses.  I have this as future reference. :)

Labels