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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
mauriziob
Contributor
Contributor

Load a file with sql conditioning to another file

Hi, i've to load a file but the records must be conditioning to another load.

Example:

LOAD

  A  as [key1], B  as [CodeFile01_B], C  as [CodeFile01_C];

SQL

   select A, B, C from lib01.File01;

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D], where exists(A);

SQL

   select AA, BB, CC, DD from libe02.File02;

The record of File02 must be load if this exist in File01.

Can i make this operation?

If i launch the script there isn't any error but the second load doesn't load any record!

Thanks.

1 Solution

Accepted Solutions
alexandros17
Partner - Champion III
Partner - Champion III

Change

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D], where exists(A);

SQL

   select AA, BB, CC, DD from libe02.File02;

in

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D], where exists([key1,A);

SQL

   select AA, BB, CC, DD from libe02.File02;

let me know

View solution in original post

4 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Change

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D], where exists(A);

SQL

   select AA, BB, CC, DD from libe02.File02;

in

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D], where exists([key1,A);

SQL

   select AA, BB, CC, DD from libe02.File02;

let me know

anbu1984
Master III
Master III

Since you renamed your field, you should use alias

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D] where exists([key1]);

SQL

   select AA, BB, CC, DD from libe02.File02;

mauriziob
Contributor
Contributor
Author

Hi, the alias without the old field name don't function! I followed indication of Alessandro. Thanks to all.

anbu1984
Master III
Master III

[key1] - Refers to field in first load

A - Refers to field in your second load

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D], where exists([key1],A);



You cannot use alias in where if it is created in same Load (Ex: Load A as B From Resident Temp Where B > 1 -- This won't work). My reply didn't work since [key 1] was not present in where clause. You can try like this


Load * where exists([key1]);

LOAD

  A  as [key1], B  as [CodeFile02_B], C  as [CodeFile02_C], D  as [CodeFile02_D];

SQL

   select AA, BB, CC, DD from libe02.File02;