Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
quriouss
Creator III
Creator III

Can a script be looped to reload data with different variables?

  1. I have a load script to load data from SAP BW.  It uses lots of long, technical names and is user-unfriendly.
  2. SAP BW also has a limit on how much data is returned from a query. My query will not give me all the data I want all at once.

Currently I have multiple copies of my SAP BW query, at the moment splitting my data into annual chunks.  I load 2010 from the 2010 query, then 2011, then 2012, etc. and Qlik Sense joins it all together neatly.

I am now looking at streamlining the process to avoid duplication of BW queries and am using WHERE {[0CALYEAR].[2010]} to load the data one year at a time, but I still have multiple copies of the MDX query in my Qlik Sense script.

Since the MDX doesn't change (apart from the year), is it possible to;

  • assign a variable
  • run the load script
  • increment the variable
  • then re-run the load script with a loop?

Thanks for any pointers.

1 Solution

Accepted Solutions
quriouss
Creator III
Creator III
Author

Oh yes, it is!!!

For vYear = 2010 to 2015                                  //defines loop variable

          Load

              <Insert Load Script here, with definitions & MDX/query>

          WHERE {[0CALYEAR].[$(vYear)]};          // This is where my variable is used

Next vYear                                                        // Loops round

View solution in original post

1 Reply
quriouss
Creator III
Creator III
Author

Oh yes, it is!!!

For vYear = 2010 to 2015                                  //defines loop variable

          Load

              <Insert Load Script here, with definitions & MDX/query>

          WHERE {[0CALYEAR].[$(vYear)]};          // This is where my variable is used

Next vYear                                                        // Loops round