5 Replies Latest reply: Nov 30, 2017 9:11 AM by Bert Abbeel RSS

    Using index value in a FOR loop when loading data?

    Bert Abbeel

      So I'm new to Qlik and can't find out why the following script won't work:

       

      SET vStartColumn = 2003;

      SET vEndColumn = 2007;

      SET vExcelName = "Budget";

       

      FOR i = vStartColumn TO vEndColumn

       

        LOAD

          Office,

          EmployeeID,

          i AS Year, // This is where the error occurs.

          "$(i)" AS Budget

       

        FROM [lib://Datasources/$(vExcelName).xls]

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

        WHERE isnull("$(i)")=0 and "$(i)">0;

       

      Next

       

      The issue as I see it is when I try to use i as a numerical input in the load script. Somehow Qlik tries to turn it into a field name.

      How can I solve this issue?

       

      Kind regards.