2 Replies Latest reply: Feb 15, 2012 11:24 AM by Mark Saunders RSS

    Using variables in a For... Loop

      I am trying to load data from several data sources that is in identical format in each source. Each time I load the data I need to tag it with the product type. The file name to load from and the product type to tag the data with are stored as a variables. I want to be able to loop through my load code for the various variable names.

       

      So for each of the multiple product types I want to load the following code, using variables varProduct1, varFile1, varProduct2, varFile2, varProduct3...

       

      TableX:

      Add LOAD

           $(varProduct1) as Product,

           *

      FROM

      [$(varFile1)]

      (biff, embedded labels, header is 1 lines, table is ProdData$);

       

      Something like -

       

      For a = 1 to 9

           TableX:

           Add LOAD

                $('varProduct'&$(a)) as Product,

                *

           FROM

           [$('varFile'&$(a))]

           (biff, embedded labels, header is 1 lines, table is ProdData$);

      Next a

       

       

      However QlikView doesn't like $('varProduct'&$(a)) or $('varFile'&$(a)). Is it possible to string together text and a variable value and get QlikView to recognise it as a variable?