Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
evansabres
Specialist
Specialist

Multiple Sheets from File

Hello -

My data source is an Excel (.xlsx) file with four (4) sheets, each with a different name and different data on each.

I know how to do a loop script when the data has the same fields on each sheet, but wondering if this is possible with different data.

My sheet names are 'traffic' 'duration' 'referrer' 'content'

Thank you.

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Since the fields are different, the only thing you can do is load them with the generic "*" for all fields and no transformations. Something like this (typing it from memory, so forgive me if the syntax is not exact:)

FOR EACH vSheet IN 'traffic', 'duration', 'referrer', 'content'

$(vSheet):

LOAD

     *

FROM

[... file name ... Table=$(vSheet)]

;

NEXT

Something along these lines... Copy the exact syntax of the FROM clause from the File Wizard.

cheers,

Oleg Troyansky

Upgrade your Qlik skills at the Masters Summit for Qlik - coming soon to Milan, Italy!

View solution in original post

5 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Since the fields are different, the only thing you can do is load them with the generic "*" for all fields and no transformations. Something like this (typing it from memory, so forgive me if the syntax is not exact:)

FOR EACH vSheet IN 'traffic', 'duration', 'referrer', 'content'

$(vSheet):

LOAD

     *

FROM

[... file name ... Table=$(vSheet)]

;

NEXT

Something along these lines... Copy the exact syntax of the FROM clause from the File Wizard.

cheers,

Oleg Troyansky

Upgrade your Qlik skills at the Masters Summit for Qlik - coming soon to Milan, Italy!

evansabres
Specialist
Specialist
Author

Sorry, I actually couldn't get this to work:

Directory 'Q:\qlkvw\prod\data\digital\HC';

FOR EACH vSheet in 'traffic', 'duration', 'referrer' , 'content';

$(vSheet):

LOAD

*

FROM


(ooxml, embedded labels, Table is $(vSheet);

NEXT

sunny_talwar

May be something like this for the attached sample

for Each file in 'A' , 'B'

Table$(file):

LOAD *

FROM

Community_205639.xlsx

(ooxml, embedded labels, table is $(file));

NEXT

sunny_talwar

You have a extra semi-colon at the end of FOR statement and you need to remove that:

Capture.PNG

sunny_talwar

In addition you are also missing a closing parenthesis at the end of your load statement:

Capture.PNG