Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

darwin_nativida
Contributor

Simple For...Next Not Working

This one is only getting the first record (aalfonso):

tblusers:

LOAD * INLINE [

Users

aalfonso

aantolini

];

     

FOR i = 0 to 1

LET arg = peek('Users',$(i));

          TEST:

          LOAD * INLINE

[

          Test

    $(arg)

];

NEXT

Tags (3)
1 Solution

Accepted Solutions
MVP
MVP

Re: Simple For...Next Not Working

Hi,

Yes, both make sense. In the first case when using Peek() you are not specifying any table, so Peek() will return the last distinct value in the field 'Users', as you will see the values of the field in a listbox. Instead, this line will return as expected (two different values):

LET arg = Peek('Users', $(i), 'tblusers');

FieldValue() returns the value with that index number sorted by load order, regardless whether the value is or is not distinct or unique.

Hope that helps.

Miguel

3 Replies
darwin_nativida
Contributor

Re: Simple For...Next Not Working

But this one works:

tblusers:

LOAD * INLINE [

Users

aalfonso

aantolini

];

    

FOR i = 1 to 2

LET arg = fieldvalue('Users',$(i));

          TEST:

          LOAD * INLINE

[

          Test

    $(arg)

];

NEXT

Any idea?

MVP
MVP

Re: Simple For...Next Not Working

Hi,

Yes, both make sense. In the first case when using Peek() you are not specifying any table, so Peek() will return the last distinct value in the field 'Users', as you will see the values of the field in a listbox. Instead, this line will return as expected (two different values):

LET arg = Peek('Users', $(i), 'tblusers');

FieldValue() returns the value with that index number sorted by load order, regardless whether the value is or is not distinct or unique.

Hope that helps.

Miguel

darwin_nativida
Contributor

Re: Simple For...Next Not Working

Thanks a lot!

Community Browser