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.
amit_saini
Honored Contributor III

Script Error Help

Hi Folks,

Is this right way of defining a loop????

For each vSheet in 'OEE','Line 1','Line 2','Line 3'

Plant:

LOAD

    left(B,3) as Plant

FROM

[amit.xlsx]

(ooxml, no labels, table is [Data $(vSheet)])

where RowNo() < 1;

Thanks,

AS

1 Solution

Accepted Solutions
MVP
MVP

Re: Script Error Help


Then try like:

For each vSheet in '(OEE)',('Line 1)',('Line 2)','(Line 3)'   // parenthesis

Plant:

LOAD

    left(B,3) as Plant

FROM

[amit.xlsx]

(ooxml, no labels, table is [Data$(vSheet)])                    // No space

where RowNo() < 1;


NEXT vSheet

9 Replies
MVP
MVP

Re: Script Error Help

You are missing a 'NEXT' at the end.

Re: Script Error Help

You missed the NEXT at the end

For each vSheet in 'OEE','Line 1','Line 2','Line 3'

Plant:

LOAD

    left(B,3) as Plant

FROM

[amit.xlsx]

(ooxml, no labels, table is [Data $(vSheet)])

where RowNo() < 1;

NEXT

amit_saini
Honored Contributor III

Re: Script Error Help

Hi Tresesco,

I do have Next at the bottom which I missed , My concern here whether this [Data $(vSheet)] is fine or not????

Not applicable

Re: Script Error Help

What is Data for?

Is your sheet name Data Line 1? If your sheet name is simply OEE, Line 1, Line 2... etc.

Use

For each vSheet in 'OEE','Line 1','Line 2','Line 3'

Plant:

LOAD

    left(B,3) as Plant

FROM

[amit.xlsx]

(ooxml, no labels, table is [$(vSheet)])

where RowNo() < 1;

NEXT vSheet

MVP
MVP

Re: Script Error Help

It seems fine. You might check for appropriation of space in the sheet name.

Re: Script Error Help

Yes it will work, just try it and you'll see. On condition that the sheets are named 'Data OEE', 'Data Line 1' and so on.

What happens is this: before each successive execution of the LOAD statement, the script engine will pre-scan the text of the LOAD statement (including the table name and semicolon), and replace all occurrences of dollar substitution strings with their respective values. The funny thing is, you can replace everything with a $(name) tag, even the table name, the LOAD keyword and the semicolon. Not that it serves any use

Peter

amit_saini
Honored Contributor III

Re: Script Error Help

I'm having one excel sheet with name as Data(OEE), Data(Line 1)....and so on

Thanks

AS

Not applicable

Re: Script Error Help

Use

For each vSheet in 'OEE','Line 1','Line 2','Line 3'

Plant:

LOAD

    left(B,3) as Plant

FROM

[amit.xlsx]

(ooxml, no labels, table is [Data($(vSheet))])

where RowNo() < 1;

NEXT vSheet

MVP
MVP

Re: Script Error Help


Then try like:

For each vSheet in '(OEE)',('Line 1)',('Line 2)','(Line 3)'   // parenthesis

Plant:

LOAD

    left(B,3) as Plant

FROM

[amit.xlsx]

(ooxml, no labels, table is [Data$(vSheet)])                    // No space

where RowNo() < 1;


NEXT vSheet

Community Browser