Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help

Hi Community,

I have three sheets in my EXCEL file..

how to read three sheets at a time using for loop

i have seen many posts in Community, but  i am unable to get

please help me..

am attached one file

Thanks in Advance..........

2 Replies
Not applicable
Author

Hi,

What you're looking for is probably something like this:

SET i = 1;             // set the starting value for variable "i"    

FOR i = 1 to 4      // instruct the for loop to count from 1 to 4

     LET sheetSelection = pick(i, 'India', 'Eng', 'NZ', 'SriLanka');    // for i = 1 India will be selected, for i = 2 England, etc.

     // NoConcatenate

     [$(sheetSelection)]:                                                            //  table name based on value of i

     LOAD

          Name,

          Born,

          Country,

          Tests,

          ODIs,

          T20s,

     FROM

          [..\..\..\..\..\Downloads\Players.xls]                              // this patch will depend on the location of your model

          (biff, embedded labels, table is [$(sheetSelection)$])     // sheet selected based on value of i

     ;

NEXT

At the end of this those four tables will have been auto-concatenate into one table(because they all have the same field names), but if you don't want this then uncomment the 'NoConcatenate' above the load script.

Hope This Helps,

Charles

Not applicable
Author

Hi Charles,

It's fine for me, Suppose adding some new sheets, but i don't know how many sheets

in my EXCEL file

Thanks..