Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Difference between peek() and previous() function

What is difference between peek() and previous() function.

Regards

Ashish Srivastava

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

Output is the table you're creating. Input is the table you're reading from.

OutputTable:
LOAD field
RESIDENT InputTable;

View solution in original post

15 Replies
Not applicable
Author

Hi Ashish,

I think the difference between Peek and Previous is that Previous always returns the data present in the previous row of the table but Peek can return data from any row based on the row mentioned in the function.

eg. previous(value) returns the data for 'value' from the previous row

peek(Value,-3) returns the 3rd last record loaded into the table.

previous(value) and peek(value) will return the same record from the previous row

Cheers,

Haneesh

johnw
Champion III
Champion III

Previous looks at your INPUT table. Peek looks at your OUTPUT table.

Not applicable
Author


Dear John

Thanks for reply .

But I don't understand what is INPUT table and OUTPUT table.

Regards

Ashish Srivastava

johnw
Champion III
Champion III

Output is the table you're creating. Input is the table you're reading from.

OutputTable:
LOAD field
RESIDENT InputTable;

Not applicable
Author

Thank John now i understood.

Regards

Ashish Srivastava

Not applicable
Author

Hi John. If you do a concantenate Load and you use a Peek function in the Load statement, how would this affect the working of Peek? I've just spent a lot of troubleshooting time on some Peeks that would not behave because of the Concatenate qualifier and I'm wondering why. Thanks for your always valuable input!        (apologies for this being all on one line. for some reason I can't press 'enter' in this edit box )

johnw
Champion III
Champion III

I'm actually not certain how it would work with a concatenate load.  I would think that the peek() should be able to refer to ANY row in the table you're building, even those that existed before you started concatenating the last source of data.  But it certainly wouldn't surprise me if I'm wrong.  It would almost surprise me more if I'm right.  What are you seeing happening?

IAMDV
Luminary Alumni
Luminary Alumni

John - Thank you for the explanation.

Ashish - The post you had marked answered is not really the answer. It is confusing for other users who want to read this thread. I think it should be John's post which should be the answer.

Many thanks - DV

johnw
Champion III
Champion III

I decided to test out peek() with concatenate.  You can indeed refer to rows that were in the table before you started concatenating.  This script:

Data:
LOAD * INLINE [
ID, Value
1, 1
2, 2
3, 3
];
CONCATENATE (Data)
LOAD 4 as ID, peek('Value') as Value
AUTOGENERATE 1
;
CONCATENATE (Data)
LOAD ID+4 as ID, peek('Value',-4) as Value
RESIDENT Data
;

Produced the results I thought it should produce:

ID Value
1  1
2  2
3  3
4  3
5  1
6  2
7  3
8  3