循环遍历数组以在 qlikview 中加载数据

loop through array to load data in qlikview

我正在使用语句在 qlikview 中加载数据

/ /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'; 

这条语句完美地加载了数据,但它不是动态的,因为如果我想将 @10 更改为某个不同的值,我必须直接对脚本进行更改,我正在寻找一种循环的方式包含这些值的数组并将数据加载到 table

类似于创建变量

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

我可以在遍历数组中的值并加载数据的 where 子句中使用它

您可以随时使用匹配功能:

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

//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]
     From 
        \cagesre005\*GLDetl* (txt, codepage is 1252, no labels, delimiter is ';', msq)
    Where 
        Match( @10, $(vDocTypes) ) > 0
 ;