[resolved] Activate Expression filter multiple clause

Six Stars

[resolved] Activate Expression filter multiple clause

Hi,
I have two requirements where I have to reject rows. The first one is working great but I do not know how to add the second requirement. The two requirements are totally variant from each other and need to be dealt separately. My second requirement is to throw out the Reid, John and Cindy with the date 3/8/2015 into the tpostgresqloutput_2 like I am doing with the unknown values from the Builder column. I want to know if I can apply two if statements in the same expression filter affecting totally different rows. I have added a comma after the first requirement to show that the two requirements are two different if clauses.
    !"unknown".equals(row1.Builder),
    !"Reid, John & Cindy".equals(row1.Last_Name_First_Name) && row1.Actual_Sale_Date=="3/8/2015"

Accepted Solutions
Community Manager

Re: [resolved] Activate Expression filter multiple clause

Thanks Sabrina,
Should I also name the second set of tpostgreSQLoutputs the same as the first set?

Sorry, I don't understand your question. BTW, I am Shong, not Sabrina.Smiley Wink
this line threw out an error:
string and date operand error.

What's data type of Actual_Sale_Date column?
If String, the expression should be:
(!"Reid,John & Cindy".equals(row1.Last_Name_First_Name)) && row1.Actual_Sale_Date.equals("03/08/2015")
If Date:
(!"Reid,John & Cindy".equals(row1.Last_Name_First_Name)) && TalendDate.formatDate("dd/MM/yyyy",row1.Actual_Sale_Date).equals("03/08/2015")

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business

All Replies
Community Manager

Re: [resolved] Activate Expression filter multiple clause

Hi 
It is impossible to add different filter conditions in the same field. As a workaround, duplicate the input data and do the filter two times, eg:
...tfileinputDelimited--main..tReplicated--main--tMap1(do filter1)--
                                                         --main--tMap2(do filter2)--
Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: [resolved] Activate Expression filter multiple clause

I do not understand Sabrina, do you I need to add two more tPostgresqloutput since I have to add one more tMap? Please provide me with an image which can guide me. I need to add two filters overall.
Community Manager

Re: [resolved] Activate Expression filter multiple clause

Yes, you need to add different tPostgresqlOutput components for each filter operation.
...tfileinputDelimited--main..tReplicated--main--tMap1(do filter1)--out1--tPostgresqloutput1
                                                                                          --reject1--tPostgresqloutput2
                                                       --main--tMap2(do filter2)--out2--tPostgresqloutput3
                                                                                           --reject2--tPostgresqloutput4
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: [resolved] Activate Expression filter multiple clause

Thanks Sabrina,
Should I also name the second set of tpostgreSQLoutputs the same as the first set?
e.g.
treplicate-------->tmap1------>tpostgreSQLoutput (mytable)
                         tmap1------>tpostgreSQLoutput (rejectedtable)
----------------------tmap2-------->tpostgreSQLoutput(mytable)
                           tmap2-------->tpostgreSQLoutput (rejectedtable)
My second filter is 
!'Reid,John & Cindy'.equals(row1.Last_Name_First_Name) && row1.Actual_Sale_Date == '03/08/2015'
this line threw out an error:
string and date operand error.
Community Manager

Re: [resolved] Activate Expression filter multiple clause

Thanks Sabrina,
Should I also name the second set of tpostgreSQLoutputs the same as the first set?

Sorry, I don't understand your question. BTW, I am Shong, not Sabrina.Smiley Wink
this line threw out an error:
string and date operand error.

What's data type of Actual_Sale_Date column?
If String, the expression should be:
(!"Reid,John & Cindy".equals(row1.Last_Name_First_Name)) && row1.Actual_Sale_Date.equals("03/08/2015")
If Date:
(!"Reid,John & Cindy".equals(row1.Last_Name_First_Name)) && TalendDate.formatDate("dd/MM/yyyy",row1.Actual_Sale_Date).equals("03/08/2015")

Regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
Six Stars

Re: [resolved] Activate Expression filter multiple clause

Thanks Shong not Sabrina!!!!