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

Function peek does not work with a LOAD statement

Hello,

I have a problem with peek function when using a load statement:

Let's say there is a table called 'ListTickets', with one field 'Ticket', and only three values : A, B, and C

I would like to use the peek function with each row one at a time, save the value in a variable, and use the variable in a load statement

My code is:



ListTickets:

LOAD * INLINE [

Ticket

A

B

C

];

for a=0 to 2

let teest = chr(39) & peek('Ticket', $(a), ListTickets) & chr(39);

TableX:

load $(teest) as TicketTest

AutoGenerate(1);

next






Unfortunately, I do not understand the behaviour of the script

  • On the first loop (when a=0), 'teest' gets the value A (as expected), and the load statement works great.
  • On the second and third loop (when a=1 or a=2), 'teest' gets the value NULL (I expect values B and C)

If I write :

  • let teest = peek('Ticket',0, ListeTickets);

  • let teest = peek('Ticket',1, ListeTickets);

  • let teest = peek('Ticket',2, ListeTickets);



before any LOAD statement, I have no problem, teest has the expected values (A, B, and C) [:)]

after the LOAD statement, teest has always NULL as value [:@]

Do you know what happens ?

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hello Pierre,

I've done a few changes to your script, and it works fine for me

ListTickets:LOAD * INLINE [TicketABC]; FOR a = 0 TO 2 LET teest = PEEK('Ticket', $(a), 'ListTickets'); // Fields are case sensitive, both field and table name must be quoted TableX: LOAD '$(teest)' as TicketTest // I use single quotes here, instead of using them as chr(39) in the variable above AUTOGENERATE (1); NEXT


Hope this helps

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hello Pierre,

I've done a few changes to your script, and it works fine for me

ListTickets:LOAD * INLINE [TicketABC]; FOR a = 0 TO 2 LET teest = PEEK('Ticket', $(a), 'ListTickets'); // Fields are case sensitive, both field and table name must be quoted TableX: LOAD '$(teest)' as TicketTest // I use single quotes here, instead of using them as chr(39) in the variable above AUTOGENERATE (1); NEXT


Hope this helps

Not applicable
Author

Hi Miguel

Thanks a lot for your help !

It seems the problem is coming from the quotes that I forgot when specifying the table name in the peek function.

In QV help, it is explained that the table name should not be between quotes, and clearly it works with quotes...

Thanks again Smile

Not applicable
Author

Hi Pierre (Miguel),

this is absolutly correct. In the help it looks quite the other way as it is in reality. Don't bother, this is a trap I felt in about 10...... times 😉

Regards, Roland