Alteryx Designer Desktop Discussions

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

CONTAINS and REPLACE REPLACE

wonka1234
10 - Fireball

Hi,

 

I am trying to figure out why my formula doesnt work, 

 

How come this doesnt work

 

Contains(Replace(Replace([N_VALUE],"SECURITY ROLE", ""), "SECURITY", "")) or
Contains(Replace(Replace([N_VALUE],"SECURITY GROUP", ""), "SECURITY", ""))
Then "Yes"

2 REPLIES 2
IraWatt
17 - Castor
17 - Castor

Hey @wonka1234,

If you look at the contains function in the docs: String Functions | Alteryx Help It requires two parameters:

One the string you are looking at

Two the string you are looking for

 

You have only given it the first part you need to add a comma and say what your looking for. Also an IF statement needs an IF an ELSE and an ENDIF.

 

The community has some quick and easy videos on formulas and the Formula Tool here https://community.alteryx.com/t5/Interactive-Lessons/tkb-p/interactive-lessons/label-name/Writing%20...

 

You could write your formula like this for instance:

IF
Contains(Replace(Replace([N_VALUE],"SECURITY ROLE", ""), "SECURITY", ""), "Example") or
Contains(Replace(Replace([N_VALUE],"SECURITY GROUP", ""), "SECURITY", ""), "Example")
Then "Yes"
ELSE 
"No"
ENDIF

Any questions or issues please ask

Ira Watt
Technical Consultant
Watt@Bulien.com 

 

 

Luke_C
17 - Castor
17 - Castor

Hi @wonka1234 

 

Perhaps you can share what you're trying to accomplish (sample data > expected result). A few quick observations:

  1. Your contains formulas aren't doing anything. What are you checking for?
  2. It looks like you're trying to do an if statement. the syntax is: IF x then y else z endif

 

A more complete formula might be something like this (you'll have to fill in the big red questions):

 

IF Contains(Replace(Replace([N_VALUE],"SECURITY ROLE", ""), "SECURITY", ""),'CONTAINS WHAT?')

or Contains(Replace(Replace([N_VALUE],"SECURITY GROUP", ""), "SECURITY", ""),'CONTAINS WHAT?')
Then "Yes"

Else 'ELSE WHAT?'

endif

Labels
Top Solution Authors