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

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

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

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

View solution in original post

3 Replies
Qvmaster2019
Creator
Creator
Author

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?

Miguel_Angel_Baeyens

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

Qvmaster2019
Creator
Creator
Author

Thanks a lot!