Qlik Community

QlikView Layout & Visualizations

Discussion Board for collaboration on QlikView Layout & Visualizations.

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
MVP
MVP

Re: Looping while loading the data

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
3 Replies
annafuksa1
Contributor III

Re: Looping while loading the data

can you attach a file ?

Not applicable

Re: Looping while loading the data

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

MVP
MVP

Re: Looping while loading the data

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
Community Browser