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

exit loop in while ....iterno()

In my load script I have code like this :

Load:

Employee,

Start_date,

addmonths(Monthstart(Startdate),iterno()-1 as month_present

Resident employee_base

while End_date > addmonths(Monthstart(Startdate),iterno()-1;

Per employee there are multiple records with start_date and end_date

the script runs fine

In some cases in one of these records there is a field named [succes_date] containing a date

Now I would like to exit the script when the field success_date contains a date and some other fields meet certain conditons

Should something be possible like this ?

while (End_date > addmonths(Monthstart(Startdate),iterno()-1) or

((success_date > addmonths(Monthstart(Startdate),iterno()-1) and otherfield1=xxx and otherfield2= xxxx );


So far I did not succeed,





3 Replies
ahaahaaha
Partner - Master
Partner - Master

Hi,

If I understood you correctly, While and IterNo() you use to read one record several times. To exit the script, you must use the operator Where.

It should be noted that in one reading cycle of your table you can not apply both operators Where and While simultaneously (at least in my practice it was not possible). Therefore, the table should be read twice, approximately as shown below.

Table1:

LOAD

RecNo() as ID,

RecNo() as Value

AutoGenerate 10

While IterNo()<=RecNo();

NoConcatenate

Table2:

LOAD*

Resident Table1

Where ID <=5;

DROP Table Table1;


Regards,

Andrey

marcus_sommer

You could try something like this:

while if(len(trim(success_date))>0 and success_date < End_date and otherfield1=xxx and otherfield2= xxxx,

               success_date, End_date) > addmonths(Monthstart(Startdate),iterno()-1)


- Marcus

curiousfellow
Specialist
Specialist
Author

Thank you Marcus,

I tried your solution and it worked.