Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
debabrata_sahoo
Contributor III
Contributor III

How to Pass colum in for loop

Hi All,

I have list of shipment id in a qvd. How I will use these id in for loop to run another sql query sql Script. 

Example;

Shipment id

91064
94353
98477
98478
98479
98480
98481
98482
98483
98528
98564
98565

SQL select col1,col2 from table1 where Shipemetid = ? (Output should based on all shipment id in qvd)

Here I can't use IN operator .  Please help on above requirements.

 

Thanks,

Deb

1 Solution

Accepted Solutions
Vegar
MVP
MVP

The script below will query the database multiple times, but it will do the trick without using IN().

For each vShipmentID in FieldList('shipmentListField')
//autoconcatenate
Shipments:
LOAD*;
SQL select * from Source where ShipmentID = $(vShipmentID);
NEXT vShipmentID

View solution in original post

4 Replies
marcus_sommer

If there are not too many ID's you could use IN(), for example with:

ShipmentID: load concat(ID, ',') as ID from ShipmentID;
let vShipmentID = peek('ShipmentID', 0, 'ShipmentID');

SQL select * from Source where ShipmentID IN($(vShipmentID));

- Marcus

debabrata_sahoo
Contributor III
Contributor III
Author

Thanks  Marcus

Vegar
MVP
MVP

The script below will query the database multiple times, but it will do the trick without using IN().

For each vShipmentID in FieldList('shipmentListField')
//autoconcatenate
Shipments:
LOAD*;
SQL select * from Source where ShipmentID = $(vShipmentID);
NEXT vShipmentID
marcus_sommer

What speaks against an in() where-clause? If it's not a problem to pull the whole table you could do that and filter then the data within Qlik per exists(). Otherwise it would be helpful you give a bit more background to your question.

- Marcus