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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
orawajar
Contributor III
Contributor III

[resolved] Join two table with condition

Hi master,
i want to join table Store and table Reference, then create Table Result by adding one more column to table Store as shown below :


0683p000009MBSe.png
The condition is :
if StoreCode1 match with StoreCode2, and Type1 match with Type2, i need to compare Number and Group Number, if the Number contain in GroupNumber, i will add the Value to ValueResult.

for example , see row 1 table Store,
the StoreCode "001" and Type "AAA" match with row 1 and row 2 from table Reference. But because Number "1" is between 1-5 (GroupNumber), so i add Value "1" (row 1 from table Reference) to ValueResult.
Can i do this with Talend?
Thanks before.
Labels (2)
1 Solution

Accepted Solutions
orawajar
Contributor III
Contributor III
Author

i thought i found a simple way to doing this join.
on tMap_2 i only need to set Match Model to All Matches
and then add filter to TableResult as shown below.


Thank you brother and sister for your help. problem solved, 0683p000009MACn.png
0683p000009MBww.png
0683p000009MBwx.png

View solution in original post

8 Replies
Anonymous
Not applicable

Hi,
You can use t<DB>Row component and execute a sql query that meets your "if" condition in it.
Best regards
Sabrina
Anonymous
Not applicable

Hi Eko,
The way I would go about it, is as follows:
0683p000009MBmj.png
1. First, I would extract the limit range from TABLE_REFERENCE as 'low_value' & 'high_value' (extracting them from string "1-5" into integer values 1 & 5, for further comparison). The output of this, I would store in a hash
2. Then perform an inner join of the output in hash with TABLE_STORE on 'store_code' & 'type' keys.
3. Then, check the incoming values from TABLE_STORE with the low & high limit values. If 'number' lies within the range, assign the value from TABLE_REFERENCE, else a zero.
4. In present scenario, since we have 2 range conditions for each unique pair of 'store_code' & 'type', the tMap join would give double the number of input rows from TABLE_STORE.
5. to eliminate redundancies, I used a tAggregateRow component. If required, if the order of records is important in the output, we can use a tSortRow component.
The output I received, is as desired:

0683p000009MBmO.png
I've tried to outline the approach. Hope this helps. 0683p000009MACn.png
Let me know if you need further assistance.
MathurM
orawajar
Contributor III
Contributor III
Author

Thanks xdshi for your quick answer, im sorry i forgot to tell you that my table is in csv file.  if you dont mind i will try mathurm solution first. 0683p000009MACJ.png
Hi mathurm, Thanks for your solution. i understand the outline but still hard for me to follow your instruction using talend. i am a beginner here. 0683p000009MACJ.png.  can you please show me the screenshoot of each component's attribute? i will appreciate it so much.
Thank you.
Anonymous
Not applicable

Hi Eko,
This would be a lot of screen-shots. 0683p000009MAB6.png
Let me try,
The first sub-jobgoes like this:
1. TABLE_REFERENCE input : to read the reference file
2. tMap2: to extract the range
0683p000009MBla.png
3. tHashOutput: to store the output of tMap2

0683p000009MBt5.png
Anonymous
Not applicable

The 2nd sub-job will be like :
1. TABLE_STORE: input component to read store file
2. tMap_1 : to check the range & assign values accordingly

0683p000009MBwm.png
3. tAggregateRow_1 : to eliminate duplicates (which will definitely be present)

0683p000009MBwr.png
4. (if required) tSortRow_1 : if the output rows are required to be sorted

0683p000009MBqz.png
I hope this should help you creating it at your end. 0683p000009MACn.png
MathurM
orawajar
Contributor III
Contributor III
Author

i am sorry i had much job last week.
Thank you mathurm for your answer. i still working on this. i will tell you if im done or have a problem with this.  0683p000009MACn.png
Best regards,
orawajar
Contributor III
Contributor III
Author

i thought i found a simple way to doing this join.
on tMap_2 i only need to set Match Model to All Matches
and then add filter to TableResult as shown below.


Thank you brother and sister for your help. problem solved, 0683p000009MACn.png
0683p000009MBww.png
0683p000009MBwx.png
Anonymous
Not applicable

Hi  orawajar,
Thanks for sharing your solution with us.
Best regards
Sabrina