Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Looping multiple times

How can I modify the script below to loop through each QVD file location? The script looks at a file location for a QVD, grabs the name of the table and counts the records in that table. I would like to do it multiple times through multiple locations.

let numRows = QvdNoOfRecords('\\filename.qvd');

let table = QvdTableName ('\\filename.qvd');

recordCount:

load * inline [

QvdTableName,numRows

$(table),$(numRows)

];

6 Replies
Not applicable
Author

You can loop through For Next loop in the script:

Find below sample snippet

SUB DoDir (Root)

FOR Each File in filelist (Root&' \*.qvd')

let numRows = QvdNoOfRecords('$(File)');

let table = QvdTableName ('$(File)');

recordCount:

load * inline [

QvdTableName,numRows

$(table),$(numRows)

];

NEXT File

FOR Each Dir in dirlist (Root&' \*' )

call DoDir (Dir)

NEXT Dir

ENDSUB

CALL DoDir ('C:')

Not applicable
Author

Do I put this in my load script?

Not applicable
Author

Hi,

What if I need to look into different instances as well like dev, QA, UAT and Prod.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Yes.

There are two parts in this piece of code. A SUB...END SUB definition which defines but doesn't execute a callable procedure, and the CALL of that same SUB (last line) which executes the procedure with a starting directory as parameter.

Always put the definition before the first CALL or you will get a script error. You can put the definition on the first script tab (together with any other SUB definition), and CALL it anywhere else on the following tabs.

Peter

swuehl
MVP
MVP

Just out of curiosity, is your original code snippet part of a learning exercise?

Count of records

Peter_Cammaert
Partner - Champion III
Partner - Champion III

I think your answer has just arrived (3 posters asking for the same solution)