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() Related Query ???


Hi All,

         I am new to Qlikview.I am trying to analyse Peek() functionality ,but i am unable to understand the exact functionality of this.It will be better if someone helps me to understand by giving some example.

what are the difference outputs we get by using the following :

Peek('Fieldname',1)

peek('Fieldname',2)

...................................

peek('Fieldname',-1)

peek('Fieldname',-2)

......................................

1 Solution

Accepted Solutions
jyothish8807
Master II
Master II

Peek() is used in the script, pick()  - on the front end.  From Help:

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

Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.

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.

Tablename is a table label, see Table Labels, without the ending colon. If no tablename is stated, the current table is assumed. If used outside the load statement or referring to another table, the tablename must be included.

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.

Load A, B, numsum( B, peek( 'Bsum' ) ) as Bsum...;
creates an accumulation of B in Bsum.


pick(n, expr1[ , expr2,...exprN])

Returns the n:th expression in the list. n is an integer between 1 and N.

Example:

pick( N'A''B'4, , , )

returns 'B' if N = 2

returns 4 if N = 3

Regards

KC

Best Regards,
KC

View solution in original post

7 Replies
jyothish8807
Master II
Master II

Peek() is used in the script, pick()  - on the front end.  From Help:

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

Returns the contents of the fieldname in the record specified by row in the internal table tablename. Data are fetched from the associative QlikView database.

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.

Tablename is a table label, see Table Labels, without the ending colon. If no tablename is stated, the current table is assumed. If used outside the load statement or referring to another table, the tablename must be included.

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.

Load A, B, numsum( B, peek( 'Bsum' ) ) as Bsum...;
creates an accumulation of B in Bsum.


pick(n, expr1[ , expr2,...exprN])

Returns the n:th expression in the list. n is an integer between 1 and N.

Example:

pick( N'A''B'4, , , )

returns 'B' if N = 2

returns 4 if N = 3

Regards

KC

Best Regards,
KC
prma7799
Master III
Master III

And peek function is only use in script part we cant use it on front-end.

jyothish8807
Master II
Master II

http://community.qlik.com/docs/DOC-4073

will be helpful

Regards

KC

Best Regards,
KC
Not applicable
Author

Thank you Kc

hariprasadqv
Creator III
Creator III

Hi Abhilash,

Peek() is very usefull in several scenarios where we need to selct top or bottom value in a field of the table.

Syntax:

Peek('Field_Name',position,'Table_name');

Here position will be represented with two values 0/-1.

Position 0=Return first Position values of that field in the specified table.

Position -1=Return Last position values of that field in the specified table.

Ex:

Table1:

SNO COUNTRY

1     India

2     US

3     UK

Peek('COUNTRY',0,'Table1') will return India.

Peek('COUNTRY',-1,'Table1') will return UK.

jyothish8807
Master II
Master II

Your welcome Abhilash

Regards

KC

Best Regards,
KC
ravindraa
Creator
Creator


Hi Abhilash,

   peek functon return the values from coresponding field based on the specified intiger value wise.

syntax : peek('FieldName',interger,'TableName')

ifwe mention Integer as 0 - it returns first record

if we mention interger as 1 - it returns second record

ifwe mention interger value as -1 - it returns last first record.

Regards

Ravindra