Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

nsnybs21qv
New Contributor III

For loop for Quarter

Hi,

I'm extracting a large amount of data from a SQL server database. There's a limit on the amount of data that can be pulled per query, so I need to query data quarter by quarter. I'm wondering if there's a for loop function in Qlikview load script that can automate this. So, I'm thinking something like.

For all quarters in current year and last two years

Data:

Load *;

SQL select *

From my table

Where mytable.quarter = quarter;

Concatenate  (Although there are several select queries , I would like to have data loaded in the same table in qlikview)

Next quarter.

Is it possible or any other suggestions?

Thanks

Yvonne

Tags (1)
1 Solution

Accepted Solutions

Re: For loop for Quarter

If your table contains identifiable quarters, dsignated with for example a string like Q1, Q2, Q3 and Q4 (or anything else you can enumerate), the na FOR EACH loop like this will do:

FOR EACH vQuarter IN 'Q1', 'Q2', Q3', 'Q4'

  Data:

  LOAD ... ; // Not needed when no field modifications

  SQL SELECT * FROM mytable WHERE mytable.quarter = '$(vQuarter)';

NEXT

QlikView will perform an AUTOCONCATENATE as soon as it detects similar loads.

Best,

Peter

2 Replies

Re: For loop for Quarter

If your table contains identifiable quarters, dsignated with for example a string like Q1, Q2, Q3 and Q4 (or anything else you can enumerate), the na FOR EACH loop like this will do:

FOR EACH vQuarter IN 'Q1', 'Q2', Q3', 'Q4'

  Data:

  LOAD ... ; // Not needed when no field modifications

  SQL SELECT * FROM mytable WHERE mytable.quarter = '$(vQuarter)';

NEXT

QlikView will perform an AUTOCONCATENATE as soon as it detects similar loads.

Best,

Peter

jsf_fasoli
Contributor II

Re: For loop for Quarter

I think this can be useful for you

for loop in qlikview with dates