Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover the Trends Shaping AI in 2026: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

tmap expression filter

Hello

I want to add a condition in expression filter. I have a fact table and a lookup table. Conditions I want to apply are when 

 Fact.Filter1 == LKP.Filter1 and for Filter2 in both tables could be either equals to each other (Fact.Filter2 == LKP.Filter2) or Lookup Filter2 is null (LKP.Filter2 == null)  or Fact Filter2 is null (Fact.Filter2 == null)  or both are null. So condition on Filter1 is a must but then for Filter2 if any one of those condition is satisfied, then the record should go in table. I am unable to formulate this in tmap expression filter. 

I tried 

Fact.FILTER1.startsWith(FILTER1)&&(Fact.FILTER2.equals(LKP.FILTER2)||Relational.ISNULL(LKP.FILTER2)||Relational.ISNULL(Fact.FILTER2)) 

But this statement fails when Fact.FILTER2 == null

How can I solve this issue?

 

Regards

Priya

Labels (1)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Hi Priya,

 

    Slight change since we have to make null check for all columns.

 

Relational.ISNULL(row1.filter2) || Relational.ISNULL(lookup.filter2) ||  (row1.filter2.equals(lookup.filter2)&& !Relational.ISNULL(row1.filter1) 
                                    && !Relational.ISNULL(lookup.filter1) 
                                    && row1.filter1.startsWith(lookup.filter1))

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

View solution in original post

6 Replies
Anonymous
Not applicable
Author

Hi Priya,

 

     The below method should work in your case.

 

0683p000009M5pS.png

 

Relational.ISNULL(row1.filter2) || Relational.ISNULL(lookup.filter2) || row1.filter2.equals(lookup.filter2)

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

Thank you @nthampi for your reply. But I cant join fact and lookup table like you suggested. If you see my code, I am joining with the help of pattern (Fact.FILTER1.startsWith(FILTER1)). How can I accomodate that?

 

 

Regards

Priya

Anonymous
Not applicable
Author

Ok. In that case, you can add this condition also in the expression area. But please make sure that any string condition comes after Null check so that you will not get any Null pointer exception.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

Anonymous
Not applicable
Author

Thank you @nthampi 

 

So my expression filter will be

(Relational.ISNULL(row1.filter2) || Relational.ISNULL(lookup.filter2) || row1.filter2.equals(lookup.filter2))&&row1.filter1.startsWith(lookup.filter1))

I am correct?

 

Regards

Priya

Anonymous
Not applicable
Author

Hi Priya,

 

    Slight change since we have to make null check for all columns.

 

Relational.ISNULL(row1.filter2) || Relational.ISNULL(lookup.filter2) ||  (row1.filter2.equals(lookup.filter2)&& !Relational.ISNULL(row1.filter1) 
                                    && !Relational.ISNULL(lookup.filter1) 
                                    && row1.filter1.startsWith(lookup.filter1))

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂

 

Anonymous
Not applicable
Author

Thank you so much! this worked..