Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Restrict Incoming records by writing multiple conditions in tmap Expression filter

Hi everyone,

My requirement is to load data from excel to oracle table which satisfies the condition written in tmap expression filter and I'm storing the rejected records in one file.

 

For example: In excel file which contains following records

VendorName,Type,Payment

John,Credits,10.23

Richard,credits,10.23

Maddy,credits,12.45

ABCD,Debit,12.87

cdef,debit,14.65

 

Expected output:

vendorname(varchar),Type(varchar),Payment(bigdecimal)

VendorName,Type,Payment

John,Credits,10.23

Richard,credits,10.23

 

Rejected records are :

Maddy,credits,12.45

ABCD,Debit,12.87

cdef,debit,14.65

 

The condition in tmap expression filter:

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23)

 

In my case, its works fine for the single condition that is  row1.Type.equals("Credits") and All the records gets rejected for this condition row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23).

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23).

 

can anyone help me out to resolve this issues?

Labels (2)
1 Solution

Accepted Solutions
TRF
Creator III
Creator III

Hi,

 

Try to compare using:

 

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

Hope this helps.

View solution in original post

8 Replies
TRF
Creator III
Creator III

Hi,

 

Try to compare using:

 

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

Hope this helps.

cjj
Contributor
Contributor

Hi, 

 

I looks a bit like it could be down to logic formatting.

 

So you're using:

row1.Type.equals("Credits") && row1.payment == BigDecimal.valueOf(10.23)

But what you really mean is:

 

Type must equal credits AND payment must equal 10.23

 

 

The problem is, it will be reading the query as:

 

Type equals credits and payment EQUALS 10.23

 

 

It's worth separating the key conditions like so, and giving that a bash:

row1.Type.equals("Credits") && (row1.payment == BigDecimal.valueOf(10.23))

 

 

Anonymous
Not applicable
Author

@TRF is correct so long as your payment column is a BigDecimal

TRF
Creator III
Creator III

@Sara, is your case solved?
Anonymous
Not applicable
Author

Hello @TRF,

 

Thank you so much.

The below code works fine.

row1.Type.equalsIgnoreCase("Credits") &&
row1.payment.compareTo(BigDecimal.valueOf(10.23)) == 0

 

I need a clarification to restrict data for Integer,float and date syntax

Anonymous
Not applicable
Author

Hi,

 

For Date values I'm using below code 

row1.CREATION_DATE.after(TalendDate.parseDate("MM/dd/yyyy","05/17/2017"))

its working fine.

My question is how to specify some date, something like I should retrieve the record which is on 05/14/2017.

I don't want to mention "after and before " keyword I just want to specify exact date.

Is this possible?

 

TRF
Creator III
Creator III

Hi,

Try this:
row1.CREATION_DATE.compareTo(TalendDate.parseDate("dd-MM-yyyy", "05/17/2017")) == 0
Anonymous
Not applicable
Author

Hi @TRF,

 

Thanks a lot! 

 

Working Fine...