Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
Qlik Analytics Tour 2020 Online. Begins August 10th. Register Today
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Contributor III
Contributor III

For - Next parameter using variables?

Can I use a variable, expression or a Peek for the constraints in a For Next

i.e. For 1 to vCounterMax or

For 1 to peek(Column, 0)

to define a loop.  It does not seem to resolve either case.

5 Replies
Highlighted
Contributor III
Contributor III

Re: For - Next parameter using variables?

I suppose I should write these with the correct format

For i=1 to vCounterMax

or

For i=1 to peek(Column, 0)

Highlighted

Re: For - Next parameter using variables?

Perhaps this?

For i=1 to Peek('Column',0, 'Table')

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)
Highlighted
Contributor III
Contributor III

Re: For - Next parameter using variables?

Thank you Aniil,

But no luck.  It does not seem to try to resole the Peek or a Variable at all.

I get an error message window that has:

Syntax error

For i  = 1 to >>>>>><<<<<<

The part following the 'to' does not seem to get resolved to a number.

Highlighted
MVP
MVP

Re: For - Next parameter using variables?

Both worked for me:

Let vCounterMax = Peek('Field',0,'Table');

For i = 1 to vCounterMax

TRACE $(i);

Next

or

For i = 1 to Peek('Field',0,'Table')

TRACE $(i);

Next

If you are using the variable approach, what does a TRACE of your variable show?

Highlighted

Re: For - Next parameter using variables?

The only thing, I can think about your Peek() may stores String which 1 to Some String which is false? Can you screenshot the image of Trace as Stefan said?

Before develop something, think If placed (The Right information | To the right people | At the Right time | In the Right place | With the Right context)