Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

peek function

Dear all,

see the example below:

load AAA from MYTABLE where MYFIELD = '1'

let MYVAR = peek('AAA')

load AAA from MYTABLE where MYFIELD = '2'

let MYVAR2 = peek('AAA')

The problem is rising when I don't find any records in the second loading. In this case MYVAR2 has the same value of MYVAR.

How can I avoid it ? Is there a way to insert a condition ?

Help please

Thanks in advance for your support

3 Replies
Not applicable
Author

You could examine the number of records after the first load, then again after the second load to determine whether new records were concatenated.

LET vRecCount = NoOfRows('TableName');

Or you could load the AAA field to a temp field which is unique for both loads... so in the first load:

LOAD

     AAA,

     AAA as Tmp_AAA

Then in the second load:

LOAD

     AAA,

     AAA as Tmp2_AAA

Then you can peek at Tmp_AAA and Tmp2_AAA.

Then just Drop Fields to get rid of the fields after.

Not applicable
Author

The peek function without the row parameter will give the last value of the field. If no rows were concatenated, then the value would remain the same. If you need to know the last values of both loads independently, then load the values into separate fields or tables. The tables can be concatenated together after running the peek function.

Anonymous
Not applicable
Author

Thanks !!!!