Alteryx Designer Desktop Discussions

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

Use Contains in Filter Tool with Multiple Selection

zqlcancer
8 - Asteroid

Is it able to use one Contains only to filter multiple selection?

 

In my attached example, you can see it works if I use 'in'. But if I applied the same logic for contains, it does not work if I only use one contains. It worked if I use 2 contains and an 'or', but for some reason I  only need one contains, is it possible?

5 REPLIES 5
aatalai
14 - Magnetar

@zqlcancer what's your desired output?

BS_THE_ANALYST
14 - Magnetar

@zqlcancer  regex match 

using a pipe parameter which will act as your OR operator. Also, you can be strict and add \b around the word and it'll make it a word boundary if you don't want the word to be contained in larger words i.e. "tip" is in "multiple" and you might not want that:
community1.pngcommunity2.png

REGEX_Match([Field1], ".*?\bcats\b.*|.*?\bdogs\b.*")

 

Attached a workflow.

All the best,

BS

binuacs
20 - Arcturus

@zqlcancer Contains takes only one argument , so you have to use OR operator with multiple contains 

image.png

zqlcancer
8 - Asteroid

@BS_THE_ANALYST , thanks. Are the special marks(* and ?) you used wild cards? But what about the dot(I refer to .)?why do we need it?

 

If I need filter any cells which contains 1234 and 2334 from below table, shall I right the formular as

 

REGEX_Match([Entity],".1234.*|.2334.*")

 

Entity

1234ab

2345ac

1234fg

2334fb

2345bf

 

 

 

BS_THE_ANALYST
14 - Magnetar

@zqlcancer 

Anything Regex related, always just chuck the Regular Expression i.e: ".1234.*|.2334.*" into chatbotgpt and ask it to tell you what it's doing. That's always good for learning.

 

Anyway, "." is a wildcard, yes. It means any character.
".*" means any character 0 or more times.

".*?" means any character 0 or more times but is NOT (unlike .*) greedy!


Without getting too much into the weeds:
.*?WORD means keep going until you find "WORD". It doesn't care if word is half way through the text, at the very start, or at the very end.

If you imagine you have a sentence like this:
"heres a WORD and more words"

 

You'll notice I've made the first part bold as that part is currently MATCHED. In order to match then end of the sentence you need to do this:
.*?WORD.*

Basically saying, hey, keep going until you find WORD and then if there's any characters after it, match them, and if there aren't any because it's at the end of the sentence, this fine also. Reason why ... ".*" means 0, 1 or many ..

 

The issue with yours:

REGEX_Match([Entity],".1234.*|.2334.*")


You've just used a "." on it's own. 
This means your expecting ANY character before 1234 and something MUST be there. By doing .* you are saying there could be 0, 1, or many characters before it. Of course, this is more flexible.

 

Hope that helps. 

As a hidden gem: https://regex101.com/r/XlDDaB/1 
On here I've corrected HALF of your regular expression. You can see some of the lines are matched, some are not. This view should allow you to build more of a conceptual understanding. Regex101 is my goto for practicing and learning regex.

 

All the best,

BS

Labels