tFilterRow - Filter a field that contains values in the context

One Star

tFilterRow - Filter a field that contains values in the context

Hello, I want to filter a string field "EVENT_NAME" to the values in my context. My context.event is A, B, C and D.
So in the tFilterRow Advanced mode, I want to code something like this input_row.EVENT_NAME.equals(context.event). I mean input.row.EVENT_NAME.equals("A","B","C","D")
Is there a way to do it? Could you provide me the syntax to get this filter works.
Thanks in advance!
Not applicable

Re: tFilterRow - Filter a field that contains values in the context

Hello,
If I understand your problem correctly, your context variable context.event can only contain "A", "B", "C", and "D". In that case you can just use input_row.EVENT_NAME.equals(context.event) in your filter, and it should filter out all other values.
If you want to check if your field EVENT_NAME contains only one of the allowed values, you can use :
"ABCD".contains(input_row.EVENT_NAME) && input_row.EVENT_NAME.length() == 1
the second part ensures that your field is only one character, so that "AB" doesn't match for instance.
One Star

Re: tFilterRow - Filter a field that contains values in the context

Hi,
The input_row.EVENT_NAME.equals(context.event) is what I want to do to get all the rows which have "A", "B", "C" and "D". However I don't get any match. I get zero rows in my output. In my data has some "A", "B", so I should get some matched rows.
I don't know if I miss anything?
Thank you for your help!
Nine Stars

Re: tFilterRow - Filter a field that contains values in the context

Use tFilterRow combined conditions Or advanced condition:


input_row.columnName.contains("A")||

input_row.columnName.contains("B")||

input_row.columnName.contains("C")||

input_row.columnName.contains("D")||

 

Similar to:

https://community.talend.com/t5/Design-and-Development/Filter-Rows-by-Substring/m-p/74084

 

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog