Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
madhubabum
Creator
Creator

Do While Loops

Hi Experts

i am neglected to close the IF Loop with an End IF at the end.

Note : I don't know where we include the End IF statement at the end.

i am adding the code as following,....(Please suggest to me)

////////////////////////////////////    Code      //////////////////////////////

IF $(vIsReloadEnabled) = 1 THEN
LET vReloadTimeIn = Now();
TempDateRange:
Load min(YearMonth) as MinYearMonth, max(YearMonth) as MaxYearMonth resident table_S;
Let vMinYearMonth=Peek('MinYearMonth',-1,'TempDateRange');
Let vMaxYearMonth=Peek('MaxYearMonth',-1,'TempDateRange');
drop table TempDateRange;
DO
       If Right($(vMinYearMonth),2)='01' THEN
         
Let vMinDateFilter= $(vMinYearMonth)-89;
       ELSE
Let vMinDateFilter= $(vMinYearMonth)-1;
END IF;

CorrectData:
Load work,df_code,i_code,DaysToComplete from [$(vQVDDataDir)\Report_Work.qvd] (qvd)
where Year(completionDate) &num(Month(completionDate), '00')>=$(vMinDateFilter)
and Year(completionDate) &num(Month(completionDate), '00')<=$(vMinYearMonth)
and isnull(number)
and completion_code='01';

CorrectDataKPI:
Load df_code, $(vMinYearMonth) as YearMonth,
count(if(i_code=1 and DaysToComplete <=1 , work)) as Priority1A,
count(if(i_code=1 ,work)) as Priority1B,
count(if(i_code=2 and DaysToComplete <=2 , work)) as Priority2A,
count(if(i_code=2 , work)) Priority2B,
count(if(i_code=3 and DaysToComplete <=28 , work)) as Priority3A,
count(if(i_code=3 , work)) as Priority3B,
count(if(i_code=4 and DaysToComplete <=14 , work)) as Priority4A,
count(if(i_code=4 , work)) as Priority4B

Resident CorrectData group by df_code;
Let MyMessage = NoOfRows(' CorrectDataKPI ') & ' rows in KPI Table';
trace $(MyMessage);
Drop table CorrectDataKPI;
TempDateRange:
Load min(YearMonth) as MinYearMonth resident table_S where YearMonth>$(vMinYearMonth)
Let vMinYearMonth=Peek('MinYearMonth',-1,'TempDateRange');
Let vMinYearMonthLoop=Peek('MinYearMonth',-1,'TempDateRange');
drop table TempDateRange;
LOOP WHILE $(vMinYearMonthLoop) <=$(vMaxYearMonth);
Left Join (table_S)
Load * resident CorrectDataKPI;
Drop table CorrectDataKPI;


Thanks

Madhu


Labels (1)
1 Reply
marcus_sommer
MVP
MVP

It seems that the END IF; needs to placed below the last line of Drop table CorrectDataKPI; But the whole script looked quite strange and I suggest to rethink these approach. At least need such code formed with indentations to make it clear what happens where.

- Marcus