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: 
Puru
Partner - Contributor II
Partner - Contributor II

Where Exists using Single Field vs Concatenated Field

Hello Experts,

I am confused on the logic of "Where Exists" when using at a Concatenated Field.

My scenario is to load the matching fields of Field_1 and Field_2 of Table_B to Table_A;

 

Puru_2-1702607505435.png

 

So, the expected value from Table_B is to load only Filed_1 's Value "A" and Filed_2's  Value "1" using Where exists statement. 

Like below example:

Table_B:

Filed_1 Filed_2 Filed_4
A 1 456

 

However, When I am using the attached Script_1.txt, the results are wrong by loading all the values of from Table_B. 

In Other Case, If I use a Single Field for Where Exits, it is producing correct results.

Below is the script and Its result.

Script:

Puru_3-1702608428602.png

Result:

Puru_4-1702608488865.png

 

Experts, please help how to resolve. 

Thank you! 

 

 

 

 

1 Solution

Accepted Solutions
Vegar
MVP
MVP

At the Field time you are using exsists() you have already loaded A3 and B1 into the datamodel as you load the table Table_B_Final. 

Try moving the exists statement up to that Load statement instead. 

Table_A:

Load * Inline [

Field_1,Field_2,Field_3

A,1,001

A,2,003

B,3,005

];

 

NoConcatenate

 

Table_A_Final:

Load

Field_1&Field_2 as Field_1andField_2,

Field_3

Resident Table_A;

Drop table Table_A;

 

 

 

Table_B:

 

Load * Inline [

Field_1,Field_2,Field_4

A,1,456

A,3,567

B,1,789

];

 

NoConcatenate

 

Table_B_Final:

Load 

Field_1&Field_2 as Field_1andField_2,

Field_4

Resident Table_B

where Exists(Field_1andField_2,Field_1&Field_2)

;

 

Drop Table Table_B;

 

View solution in original post

3 Replies
Vegar
MVP
MVP

At the Field time you are using exsists() you have already loaded A3 and B1 into the datamodel as you load the table Table_B_Final. 

Try moving the exists statement up to that Load statement instead. 

Table_A:

Load * Inline [

Field_1,Field_2,Field_3

A,1,001

A,2,003

B,3,005

];

 

NoConcatenate

 

Table_A_Final:

Load

Field_1&Field_2 as Field_1andField_2,

Field_3

Resident Table_A;

Drop table Table_A;

 

 

 

Table_B:

 

Load * Inline [

Field_1,Field_2,Field_4

A,1,456

A,3,567

B,1,789

];

 

NoConcatenate

 

Table_B_Final:

Load 

Field_1&Field_2 as Field_1andField_2,

Field_4

Resident Table_B

where Exists(Field_1andField_2,Field_1&Field_2)

;

 

Drop Table Table_B;

 

Lisa_P
Employee
Employee

The where exists is looking at all previously loaded values in Field_1andField_2,

which are

A1 (from Table_A_Final)
A2
B3
A3 (from Table_B_Final)

So the last table will bring in all the fields from Table_B_Final.


B1

Puru
Partner - Contributor II
Partner - Contributor II
Author

Thank you @Vegar  for quick help!! Much appreciated. 

Thank you @Lisa_P  for your explanation. Much appreciated.