Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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.
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.