
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Difference between peek() and previous() function
What is difference between peek() and previous() function.
Regards
Ashish Srivastava
- « Previous Replies
-
- 1
- 2
- Next Replies »
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Output is the table you're creating. Input is the table you're reading from.
OutputTable:
LOAD field
RESIDENT InputTable;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Previous looks at your INPUT table. Peek looks at your OUTPUT table.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear John
Thanks for reply .
But I don't understand what is INPUT table and OUTPUT table.
Regards
Ashish Srivastava


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Output is the table you're creating. Input is the table you're reading from.
OutputTable:
LOAD field
RESIDENT InputTable;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank John now i understood.
Regards
Ashish Srivastava

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 )


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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?

.png)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- « Previous Replies
-
- 1
- 2
- Next Replies »