Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Using nested for each next loop to read from multiple qvd

I'm trying to use a nested for next loop to read multiple qvd having a daily signiture like ...YYYY-MM-DD.qvd.

How do I access the variables from the loop correctly to create a string that I can use to read qvd from.

for each vJahr in qvdJahr

    for each vMonat in qvdMonat

        for each vTag in qvdTag

            vFromString = $(vPath) & '\QDatei_' & '$(vJahr)' & '-' & '$(vMonat)' & '-' & '$(vTag)' & '.qvd';

            Load

                *

            Fm $(vFromString) (qvd);   

        next

    next

next

The script above stopps with an error message saying:

"Fehler beim Öffnen der Datei 'D:\QDatei_--.qvd' The system cannot find the file specified."

So the content of the variables qvdJahr, qvdMonat, qvdTag are not placed in the string whereus

the variable vPath is there.

Michael

4 Replies
Not applicable
Author

Hi Michael,

how did you define qvdJahr, qvdMonat and qvdTag variables?

regards

Anonymous
Not applicable
Author

Hi

here's the code:

qvdFiles:

FIRST 1 LOAD

    filedir() as qvdPath

    , filename() as qvdFilename

    , mid(filename(),13,4) as qvdJahr

    , mid(filename(),18,2) as qvdMonat

    , mid(filename(),21,2) as qvdTag

FROM [$(vPath)\QDatei*.qvd] (qvd);

regards

Michael

rbecher
MVP
MVP

Michael,

the for .. each needs to have the values as a list: 2010, 2011, 2012

So, this will not work. Alternatively you can loop over the table:

LET rows = NoOfRows('qvdFiles');

For i=1 to $(rows)

     let vQvdJahr=peek('qvdJahr', $(i), 'qvdFiles');

     etc.

next

- Ralf

Astrato.io Head of R&D
qlikviewforum
Creator II
Creator II

In this scenario how can i find the NoOfRows in the load statement? Something like as discussed in the below post!

http://community.qlik.com/message/263775#263775