Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
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

Re: Looping multiple times

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

Re: Looping multiple times

Do I put this in my load script?

Not applicable

Re: Looping multiple times

Hi,

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

Re: Looping multiple times

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

MVP
MVP

Re: Looping multiple times

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

Count of records

Re: Looping multiple times

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

Community Browser