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: 
pdumas
Partner - Contributor III
Partner - Contributor III

Load distinct key

Hi,

I have 2 tables that share the same key :

Tables are Data_Current and Data_Histo, with a key named Data_ID

I want to load records from Data_Current Table

and add, in the same table, records from Data_Histo for which the key Data_ID has not been already loaded from Data_Current Table.

What is the best practice in that situation?

Thanks for your help

Pierre.

2 Replies
disqr_rm
Partner - Specialist III
Partner - Specialist III

LOAD * from Table1.qvd;

LOAD * from Table2.qvd where not exists(Data_ID);

Assuming you are loading from qvd file. If this is not the case, you would need to load RESIDENT, but you would need to load Data_ID as something else. But NOT EXISTS should work fine in either case. Check out EXISTS() function documentation.

johnw
Champion III
Champion III

Is Data_ID a unique key?

[Data]:
LOAD
Data_ID
,other fields
RESIDENT [Data_Current]
;
CONCATENATE ([Data])
LOAD
Data_ID
,other fields
RESIDENT [Data_Histo]
WHERE NOT EXISTS(Data_ID)
;