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: 
Rsaiq
Creator
Creator

Remove the records which are matching in tables

Hi,

I have requirement if records matching between 2 tables then delete that records from both table.

Table1
ID Name
1 Jhon
2 Sam



Table2
ID Name
1 Carry
3 Alex

 

In Table1 & Table 2 , ID=1 is matching so need to remove records which belongs to ID=1.

I need to merge data from both tables by excluding matching records using  qliksense script, in this case ID=1 is matching so my new table should look like below

Table3
ID Name
2 Sam
3 Alex

 

Could anyone please look into it .

Thanks in advance

Labels (4)
1 Solution

Accepted Solutions
Digvijay_Singh

Could be done in multiple ways, one of the way on top of my head is like this - 

Table1:
Load * inline [
ID, Name
1, Jhon
2, Sam
];

Concatenate //Concatenate both input tables
Load * inline [
ID, Name
1, Carry
3, Alex
];


IDCount: //Identify IDs with duplicates and store in temp table
Load ID, Count(ID) as IDCount
resident Table1
Group By ID
;

Left Join(Table1) //Join temp table to input data to identify duplicate rows
Load * resident IDCount;
Drop Table IDCount;


NoConcatenate
Final:
Load *
resident Table1
Where IDCount = 1 //Only keep rows which are not duplicates between input tables.
;

Drop Table Table1;
Drop Field IDCount; //Delete Tables and fields not needed in the final output.

 

 

View solution in original post

2 Replies
Digvijay_Singh

Could be done in multiple ways, one of the way on top of my head is like this - 

Table1:
Load * inline [
ID, Name
1, Jhon
2, Sam
];

Concatenate //Concatenate both input tables
Load * inline [
ID, Name
1, Carry
3, Alex
];


IDCount: //Identify IDs with duplicates and store in temp table
Load ID, Count(ID) as IDCount
resident Table1
Group By ID
;

Left Join(Table1) //Join temp table to input data to identify duplicate rows
Load * resident IDCount;
Drop Table IDCount;


NoConcatenate
Final:
Load *
resident Table1
Where IDCount = 1 //Only keep rows which are not duplicates between input tables.
;

Drop Table Table1;
Drop Field IDCount; //Delete Tables and fields not needed in the final output.

 

 

Rsaiq
Creator
Creator
Author

HI @Digvijay_Singh 

 

Thanks for your help !!!

 

It is working fine. Thanks once again