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

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Common/Uncommon data in Two or more tables

Hi All,

We have an issue here.

We are trying to find out the common and uncommon data from two fields from two separate tables and then we are trying to add another filed (Flag) to the table which has the maximum values, which will have a value YES if data matches and NO if the data is not matching.

Please find the data as pasted below.

Table1Table2
Col1Col2
AA
BB
CX
DE
ED
FU
R
S
T

Result
Col2New column
AYes
BYes
XNo
EYes
DYes
UNo
RNo
SNo
TNo

Thanks in advance

1 Solution

Accepted Solutions
Jason_Michaelides
Partner - Master II
Partner - Master II

Hi,

You can use ApplyMap() for this:

Map_TableA:

MAPPING LOAD

  Col1,

  'Yes'

From...Table1;

Table2:

LOAD

   Col2,

   ApplyMap('Map_Table1',Col2,'No') AS [New Column]

From....Table2;

Hope this helps,

Jason

View solution in original post

6 Replies
tresesco
MVP
MVP

Try like:

Load

          Col1,

          Col2,

          If(Col1=Col2, 'Yes', 'No') as NewCol

Not applicable
Author

Thanks for your help but Col1 and Col2 are fields of two different tables and those keys are primary foreign keys. I have linked those tables with the help of these columns... Please give me solutions for this

tresesco
MVP
MVP

Could you share a sample app?

sushil353
Master II
Master II

Try the below code:

Table1:

LOAD * Inline

[

Col1

A

B

X

E

D

U

];

Table2:

LOAD Col1 as Col2,if(Exists(Col1),'Yes','No') as flag Inline

[

Col1

A

B

X

E

D

U

R

S

T

];

Its output is:

AYes
BYes
DYes
EYes
RNo
SNo
TNo
UYes
XYes

HTH

Sushil

Jason_Michaelides
Partner - Master II
Partner - Master II

Hi,

You can use ApplyMap() for this:

Map_TableA:

MAPPING LOAD

  Col1,

  'Yes'

From...Table1;

Table2:

LOAD

   Col2,

   ApplyMap('Map_Table1',Col2,'No') AS [New Column]

From....Table2;

Hope this helps,

Jason

Not applicable
Author

Thank you guys !!!