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

Peek,Previous

Hi,

what is the difference between Peek and Previous..?

when we use peek and previous...?

Sub2u    

5 Replies
maxgro
MVP
MVP

there is a detailed post here

Peek() vs Previous() – When to Use Each

hic
Former Employee
Former Employee

Previous() gets the previous record of the input to the Load statement.

Peek() with only one parameter gets the previous record of the output of the Load statement.

In addition, Peek() can get values from any previously loaded record in any table.

HIC

Not applicable
Author

can you plz elaborate

satishqlik
Creator II
Creator II

Peek()---> it can be used to reflects the data from qvw internal database

                i.e.,If we want to extract particular value from  the specified field

                Here this is the order,1st record starts from 0,2nd rec is 1 and so on -ve numbers indicate order from the end

               default row number is -1 and default table is current table.

Previous()--->it returns the value, using the data from previous input record.

In previous() no need to use single codes around the field name where as peek() it might not works some times.

prajapatiamar38
Creator II
Creator II

previous(expression ) :

Returns the value of expression using data from the previous input record. In the first record of an internal table the function will return NULL. 

peek(fieldname [ , row [ , tablename ] ] )

Returns the contents of the fieldname in the record specified by row in the internal table tablename.

Fieldname must be given as a string (e.g. a quoted literal).

Row must be an integer. 0 denotes the first record, 1 the second and so on. Negative numbers indicate order from the end of the table. -1 denotes the last record read.

If no row is stated, -1 is assumed.

Examples:

peek( 'Sales' )
returns the value of Sales in the previous record read ( equivalent to previous(Sales) ).

peek( 'Sales', 2 )
returns the value of Sales from the third record read from the current internal table.

peek( 'Sales', -2 )
returns the value of Sales from the second last record read into the current internal table.

peek( 'Sales', 0, 'Tab1' )
returns the value of Sales from the first record read into the input table labeled Tab1.