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

loop through array to load data in qlikview

I am loding data in qlikview using statement

/ /Importing data from flat file
dataimport:
LOAD  @1 AS CoCd,
@2 AS Period,
@3 AS [Doc. Date],
@4 AS [Pstng Date],
@5 AS TranslDate,
@6 AS Reference,
@7 AS DocumentNo,
@8 AS Crcy,
@9 AS Year,
@10 AS [Doc. Type],
\\cagesre005\*GLDetl*
(
txt, codepage is 1252, no labels, delimiter is ';', msq)

where @10 = 'KA' or @10 = 'KG' or @10 = 'KR' or @10 = 'KH' or @10 = 'KN' or @10 ='AB' or @10 ='IK' or @10 ='IM' or @10 ='MM' or @10 ='RE' or @10 ='RN';

this statement loads data perfectly but it is not dynamic since if I want to change the @10 to some different value I have to make change directly to the script, I am looking for a way that loop through a array containing these values and load data to the table

something like creating variable

$(vDocTypes) = 'KA','KG','KR','KH','KN','AB','IK','IM','MM','RE' ,'RN';

which I can use in where clause that goes through the values in the array and load the data


2 Replies
marcus_sommer

I'm not sure if the $-sign expansion worked within the script and maybe you will need some attempt to get the right syntax but try something like this:

set vDocTypes = "'KA','KG','KR','KH','KN','AB','IK','IM','MM','RE' ,'RN'";

...

where match(@10, $(=$(vDocTypes)));

- Marcus

mbp198
Contributor III
Contributor III
Author

Thanks Marcus, I tried Match( @10, $(vDocTypes) ) and it worked