How to use the Rule-Based Filter Node to check if any of a series of words appears in a Column


I am attempting to use the Rule-Based Row Filter to filter the “Purpose” column within the attached CSV file. I wan to include a row if the following words are within in it, in any capacity and any order, “google,” “facebook,” and “email.”

Note that there is no organization or order to each value. I also don’t care about count of rows, but the inclusion of the rows themselves.

I’ve successfully used the regular Row Filter using pattern matching and a wild card expression to check for “email,” but, I would like to be able to filter for multiple terms at one time, hence the Rule-Based Row Filter node.

See the two screenshots of a successful use of the Row Filter.

I’ve unsuccessfully tried to us the Rule-based Row Filter using the following expression, which was a suggestion from ChatGPT:
$PURPOSE$ LIKE “google” OR $PURPOSE$ LIKE “facebook” OR $PURPOSE$ LIKE “email” => TRUE

You can see my condensed workflow below:

And here is the TXT file, with the “Purpose” column I am attempting to filter:

Any idea on how I can get this done? Thank you in advance.

Hi @cholbert , unfortunately your workflow didn’t contain the csv file, so I have added some demo data (courtesy of chatGPT to save my typing!) and here is a demo of a number of ways using Row Filter and Rule Based Row Filter.

For your task you can use Regex or Wildcards. I would recommend Regex as there is a little more control, such as identifying “word boundaries”, and making it case insensitive, but I have shown examples using both regex and wildcards.

Purpose_filter demo.knwf (54.5 KB)

Your EMAIL s capital case so why do you write “email” ?

1 Like

Try this

$PURPOSE$ = “google” OR $PURPOSE$ = “facebook” OR $PURPOSE$ = “email” => TRUE

That should work

Hi @takbb!

Thanks for the quick reply! Apologies, the CSV file was inaccessible via my Google Drive. I did not give public access and I actually had to convert it to a TXT file. Your case insensitive rule-based row filters are the ones that solved my problem. Thank you for your assistance!


1 Like

I think @takbb using regex Case INSENSITIVE match solves for this one

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.