3 Replies Latest reply: Jul 31, 2013 3:59 AM by Kaushik Solanki RSS

    Loop in script returning NULL values?

    Friedrich Hofmann

      Hi,

       

      I have a code in my QlikView script doing the following:

      - Load an overview table with 15 serial_numbers (some text, some purely numeric) and the respective text;

      - Loop from 1 to 15 (there are 15 SN) and load one SN on each iteration;

      - Set a variable with the current SN;

       

      <=> At least that's what it is supposed to do.

      => The variable should then be used (still within the Loop) to load one of 15 worksheets, all of which have the same structure with similar data.

       

      I can see afterwards in a listbox that all 15 SN are loaded, one at a time. The variable, however, returns just NULL values.

      Might it be that I cannot create variables in a loop at all? If so, how can I achieve this effect (within every loop_iteration, repeat a LOAD statement for the respective SN, which is in the sheet_name)?`

      From another software I know I had to initiate variables before a LOOP to be able to use them, but that doesn't seem to work...

       

      Thanks a lot!

      Best regards,

       

      DataNibbler

        • Re: Loop in script returning NULL values?
          Kaushik Solanki

          Hi,

           

               I am not sure with what expression you are trying to do this, but have a look at the below code.

           

               DATA:

               Load SN from XYZ;

           

               Let vCount = NoOfrows('DATA');

           

               For i=0 to $(vCount) -1

              

                    Let vSN = peek('SN',$(i),'DATA');

           

               ........

           

               Next

           

          Regards,

          Kaushik Solanki

            • Re: Loop in script returning NULL values?
              Friedrich Hofmann

              Hi Kaushik,

               

              I have a somewhat simplified LOOP construction, I will post it after this. Yours does look better, it is flexible as to the nr. óf rows. I will replace that. Do I have to specify the table and row with the PEEk fct to fill my variable? At that time, there is only one field of that name.

               

              Here is the code I am currently using:

               

              Übersicht_SN:
              LOAD A as SN,
                   B as Bezeichnung,
                   RecNo() as SN_Ct
              FROM
              [S:\Quality\05 Messungen Konservierungsanlagen\Gesamtliste Messungen 2013\Juni 2013\Konservierung gesamt  Juni mit Diagram_Ver1.xlsx]
              (ooxml, no labels, header is 3 lines, table is Übersicht)
              WHERE NOT ISNULL (A);

               

              FOR i = 1 TO 15

               

                Test_Counting:
                 LOAD
                   SN as SN_test
                 RESIDENT Übersicht_SN
                   WHERE SN_Ct = $(i)
              ;

              LET v_SN = SN_test;

              NEXT i