Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to use List more efficiently in For Each...Next?

Hello,

I need to use For Each loop to run query on different schema in the same database. All the schema have the same tables with different data. Below is a sample query:

For Each vStore in 's10', 's11', 's12', 's13','s14', 's15', 's16','s17','s18', 's19'

accounts:

LOAD *;

SQL

SELECT companyid, firstname, lastname, custid

FROM $(vStore).customer as a

WHERE date(postdate) = '2011-12-31';

NEXT vStore

In the Code above it just shows 10 schema in the list (after 'in') however, I have 40 schema to run the query on. The editor forces me to add schema in the list in the same line. Is it possible to break the line in the list? when I type the stores in the next line it shows syntax error. Keeping list of 40 schema in the same line makes it difficult to read and edit the script. Any Ideas?

10 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Thanks for pointing out my mistake. I've corrected the post.

Also added the "-1" to NoOfRows()

-Rob