Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator III
Creator III

difference between Peek() and Pick() function

Hi,

Please give me an example of each function.

6 Replies
Highlighted
Specialist
Specialist

Peek function allows you to get the rows from a table based on the parameter provided

eg

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

Eg: LET varMinDate = Num(Peek('ExpenseDate', 0, 'Expenses'));

varmindate will have the first row from the expesnses table from the expensedate field

and pick function

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


pick is like an if else statement


eg

pick function in charts-----suppose different colors for different dimension values.

for example-expression--->backgroundcolor---->pick(match(country,'india','usa','uk'),red(),blue(),green())




regards

Nadeem

Highlighted
Master III
Master III

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

Highlighted
Specialist II
Specialist II

Hi,

It may helps you,

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

Regards

Krishna

Highlighted
Partner
Partner

Main difference between Peek & Pick,Peek is Inter Record Function & Pick is Conditional Function.

Regards,

Mukesh Chaudhari.

Highlighted
Creator II
Creator II

Hi Sandip,

This is best example to understand the fundamental of Pick function please go through the below link,

https://www.youtube.com/watch?v=HIBNf0YY0jY

You will sure be  happy once you implemented the same at your end

Regards,

Ali

Highlighted
Creator III
Creator III

Hi,

Simple explanation is;

pick(), it is used to pick a value at a given function.

peek(), used to extract particular record value.