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

Announcements
Qlik Connect 2026 Agenda Now Available: Explore Sessions
cancel
Showing results for 
Search instead for 
Did you mean: 
jimbo20814
Creator
Creator

tMap OR operator in JOIN

All, in tMap how can I perform what's equivalent to a SQL OR within a JOIN? For example see below.

 

SELECT * FROM MainFlow mf

JOIN LookUp lu ON mf.colA = lu.colA AND (mf.colB = lu.colB OR mf.colC = lu.colC)

 

I tried to use a expression filter but does not do the job.

 

mf.colB== lu.colB || mf.colC == lu.ColC

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable

This depends on what you want. If both conditions in the OR match, I assume you only want the 1 row returned? If so, this can be done with a combination of tMap variables and output filters. I'll demonstrate a REALLY simplified version of how to do this in a tMap below.....

0683p000009M92N.png

In this example I have two datasets, both with columns a, b and c. The join is on columns and b OR c. I do not join the input tables, which creates a cartesian join scenario. I then create two tMap variables of type boolean. I compare row1.b with row2.b to see if it matches. I also compare row1.c with row2.c to see if that matches. In the output table I apply a filter which uses the two tMap variables. If either of them are true, the row is returned. 

View solution in original post

7 Replies
cmendels
Contributor III
Contributor III

Did you place the expression in the filter on your lookup table or on your output? 

jimbo20814
Creator
Creator
Author

I placed on the lookup table. Do I need to place on output?

cmendels
Contributor III
Contributor III

I would try it on the output to see if you get the results you want.

jimbo20814
Creator
Creator
Author

Actually, no that won't work/make sense because it's really a part of the JOIN between MainFlow and LookUp, once it's the output it's too late. Hmm, I figure this is a common task/requirement, an OR in a JOIN.

Anonymous
Not applicable

This depends on what you want. If both conditions in the OR match, I assume you only want the 1 row returned? If so, this can be done with a combination of tMap variables and output filters. I'll demonstrate a REALLY simplified version of how to do this in a tMap below.....

0683p000009M92N.png

In this example I have two datasets, both with columns a, b and c. The join is on columns and b OR c. I do not join the input tables, which creates a cartesian join scenario. I then create two tMap variables of type boolean. I compare row1.b with row2.b to see if it matches. I also compare row1.c with row2.c to see if that matches. In the output table I apply a filter which uses the two tMap variables. If either of them are true, the row is returned. 

jimbo20814
Creator
Creator
Author

Bingo! thanks so much rhall_2_0.

Anonymous
Not applicable

No problem, I'm glad it helped 🙂