CONTAINS and REPLACE REPLACE
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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"
Solved! Go to Solution.
- Labels:
- Custom Tools
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator
Hi @wonka1234
Perhaps you can share what you're trying to accomplish (sample data > expected result). A few quick observations:
- Your contains formulas aren't doing anything. What are you checking for?
- 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
