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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Rajitha1
Contributor III
Contributor III

Find unmatched records from two tables

How to find unmatched records from two tables.

Rajitha1_0-1666242373324.png

 

Labels (1)
2 Replies
BrunPierre
Partner - Master II
Partner - Master II

With Mapping script prefix like this;

T1:
LOAD * Inline[
Shop Name, Qty
Store A,2
Store A,1
Store A,1
Store C,2
Store C,1
Store B,2
Store B,2];


T2:
LOAD *,
[Shop Name]&'_'&Qty as %Key,
[Shop Name]&'_'&Qty as TempField;

LOAD * Inline[
Shop Name, Qty
Store A,2
Store A,1
Store A,3
Store D,2
Store D,1
Store B,1
Store B,2
Store F,3
Store F,2
Store F,1
Store F,3];


MappingTable:
Mapping Load Distinct [Shop Name]&'_'&Qty as %Key,
[Shop Name]&'_'&Qty as TempField

Resident T1;
DROP Table T1;

FinalTable:
LOAD [Shop Name],
      Qty,
ApplyMap('MappingTable',%Key,'Unmatched') as Flag
Resident T2
Where ApplyMap('MappingTable',%Key,'Unmatched')='Unmatched'; //Comment this line to display all records (Matched and Unmatched)

DROP Table T2;

DROP Field Flag From FinalTable;

EXIT SCRIPT;
vinieme12
Champion III
Champion III

filtering for  "flag_ExistsIn_T1"  = 1 will show records from t2 which exist in table1

filtering for  "flag_ExistsIn_T2"  = 1 will show records from t1 which exist in table2

 

table1_Temp:
LOAD *
,Shop&'-'&Qty as t1_Key 
Inline[
Shop, Qty
Store A,2
Store A,1
Store A,1
Store C,2
Store C,1
Store B,2
Store B,2];

NOCONCATENATE
table2:
LOAD *
,Shop&'-'&Qty as t2_Key
, Exists(t1_Key,Shop&'-'&Qty)*-1 as flag_ExistsIn_T1 
Inline[
Shop, Qty
Store A,2
Store A,1
Store A,3
Store D,2
Store D,1
Store B,1
Store B,2
Store F,3
Store F,2
Store F,1
Store F,3];

NOCONCATENATE
table1:
Load 
Shop as t1.Shop
,Qty as t1.Qty
,t1_Key
,exists(t2_Key,t1_Key)*-1 as  flag_ExistsIn_T2
Resident table1_Temp;
Drop table table1_Temp;

 

 

 

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.