Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Looping while loading the data

I want to load the data within a loop. The following is my case,

General logic:

my_data:

ResultSet resultSet = "Select distinct designation, location from employee";

for(int i = 0; i < resultSet.count; i++) {

load emp_id,

    name,

    designation, location, salary;

sql select * from employee where location = "resultSet.location" , designation = "resultSet.designation";

}

I want the above logic should be done while loading the data. Every time it should concatenate/append with the existing data.


Please help me to get this done.

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I think this is what you are looking for:

tmpLocationDesignation:

LOAD Distinct

     Location,

     Designation

From employee;

For i = 1 To NoOfRows('tmpLocationDesignation')

     Let zLocation = Peek('Location', i, 'tmpLocationDesignation');

     Let zDesignation = Peek('Designation', i, 'tmpLocationDesignation');

     my_data:

     load emp_id,

          name,

          designation,

          location,

          salary;

  sql select * from employee

  where location = '$(zLocation)'  And designation = '$(zDesignation)';

Next

Set zLocation =;

Set zDesignation =;

Drop Table tmpLocationDesignation;

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

3 Replies
annafuksa1
Creator III
Creator III

can you attach a file ?

Not applicable
Author

Hi Rajaram,

"For next" as well as "For each next" is described with examples in the reference manual. If you have done a full installation of QlikView you can find it here :


C:\ProgramData\QlikTech\QlikView Documentation\Reference Manual


/Ida

jonathandienst
Partner - Champion III
Partner - Champion III

Hi

I think this is what you are looking for:

tmpLocationDesignation:

LOAD Distinct

     Location,

     Designation

From employee;

For i = 1 To NoOfRows('tmpLocationDesignation')

     Let zLocation = Peek('Location', i, 'tmpLocationDesignation');

     Let zDesignation = Peek('Designation', i, 'tmpLocationDesignation');

     my_data:

     load emp_id,

          name,

          designation,

          location,

          salary;

  sql select * from employee

  where location = '$(zLocation)'  And designation = '$(zDesignation)';

Next

Set zLocation =;

Set zDesignation =;

Drop Table tmpLocationDesignation;

HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein