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

Help with multiple loops

It seems simple, but I've just started working with QlikView....

I have to execute a procedure against a SQL database for each row in a spreadsheet. My qvw script already has a

loop to do this, and it is working well. The problem is, I need a second loop so I can run the existing one for different sets of dates (initial and final date variables).

                        

LET InitialDate = Date(Today()-3 , 'YYYYMMDD');

LET FinalDate   = Date(Today()-3 , 'YYYYMMDD');

Base:

LOAD    cdCompanyCode

             ,cdProductionType

FROM $(Industry)\FBPD316_Comparison.xls (biff, embedded labels, table is CompanyProductionType$) ;

LET nrRows = NoOfRows('Base');

LET iCounter = 0;

   

DO WHILE iCounter < nrRows

    LET AncdCompanyQV           = Peek('cdCompanyCode', $(iCounter), 'Base');

    LET AncdProductionType      = Peek('cdProductionType', $(iCounter), 'Base');

    SET AdInitial               = $(InitialDate);

    SET AdFinal                 = $(FinalDate);

  

    FactTable:

LOAD *

     , date(Date#($(AdInitial),'YYYYMMDD'),'DD/MM/YYYY')    AS dInitial

     , date(Date#($(AdFinal),'YYYYMMDD'),'DD/MM/YYYY')    AS dFinal;

   

SQL EXECUTE dbo.SQL_Procedure $(AncdCompanyQV)                             

                                     , '$(AdInitial)'         

                                     , '$(AdFinal)'        

                                       , $(AncdProductionType)     

    

LET iCounter = iCounter + 1;

LOOP

0 Replies