Advent of Code is back! Unwrap daily challenges to sharpen your Alteryx skills and earn badges along the way! Learn more now.

Alteryx Designer Desktop Discussions

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

Replicating Contains formula into one string

wonka1234
10 - Fireball

Hi,

 

How can I replicate my contains formula into one line? I want to do this so I can use a text input and replace this string what an input.

 

Formula =  

If Contains([Value]), "Louis) or

Contains([Value]), "Ren") 

 

 

Is there a way I can make it something like

 

Formula =  Value Contains("Louis","Ren","Thomas")

 

thanks.

16 REPLIES 16
alexnajm
17 - Castor
17 - Castor

@wonka1234 Use the IN function!

 

[Value] IN ("Louis","Ren","Thomas")

wonka1234
10 - Fireball

@alexnajm  i dont think IN works exactly as contains

alexnajm
17 - Castor
17 - Castor

@wonka1234 good call, it's not the exact same but it condenses it to one line at least.

RRaoDannayak
7 - Meteor

@wonka1234  what @alexnajm mentioned is right but just add if logic to it and you can filter it based on if else logic 

 

if [Value] in ("Me1","Me2","Me3") then "In" else "Out" endif 

this will give you the results as in and out and add a filter to it to get either In data or Out 

Additionally if you want to filter with only "Me1,2..." then give this formula 

if Contains([Value], "me1")
then "IN"
elseif Contains([Value], "me2") then "IN"
else "Out" endif

This will filter out all Me1,2... in the data, i don't think so there is another way to do it 

wonka1234
10 - Fireball

@RRaoDannayak  i dont think can be converted to a user input, thats why i wanted one line. I wanted to do it for an analytic app.

alexnajm
17 - Castor
17 - Castor

Hi @wonka1234,

 

If we have a better idea of what you are trying to accomplish by putting this logic on one line, that would be helpful! Ideally a workflow, but even screenshots would be a step forward.

 

Because from the description so far, it sounds like you have a Text Input getting updated by an Interface tool - but perhaps you could directly connect the Interface tool to the Formula tool instead!

 

-Alex

 

-Alex

Felipe_Ribeir0
16 - Nebula

Hi @wonka1234 

 

Unfortunately you will not find a way to use the contains formula different than doing contains(value, 'value1') or contains (value, 'valueN')... And there is no other string formula that do exactly the same job that the contains formula do.

 

What you can do is try to use the regex formulas to achieve the same result in a more 'condensed' way, like this:

 

Felipe_Ribeir0_0-1675372699061.png


If you manage to get your user inputs, concatenate them with | as separator and replace the value inside of thIs formula, it will work as expected.

binuacs
21 - Polaris

@wonka1234 One way of doing this. Make sure the values should be entered in line by line (using \n as delimiter)

 

binuacs_0-1675375068318.png

 

alexnajm
17 - Castor
17 - Castor

@binuacs it doesn't seem to work for more than two values as a heads up!

Labels