Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

peek() and pick() function explination pls?

peek() and pick() function explination pls?

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

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


View solution in original post

10 Replies
Anonymous
Not applicable
Author

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


Gysbert_Wassenaar

You can use pick in the script as well. Peek can only be used in the script, not in chart expressions.


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

True, thanks Gysbert.

In short, peek() is to fetch a field value from a logical table previously loaded in the script.

Pick() is to fetch an expression from the list of expressions.

Not applicable
Author

hi Manoj,

chek the Peek() vs Previous().

here is the link

http://community.qlik.com/blogs/qlikviewdesignblog/2013/04/08/peek-vs-previous-when-to-use-each

generally Pick() function used in front end application example.we can use back end as well.

in front end,

for ex dynamically displaying color of barchart having dimension country on x axis and sum(sales) on yaxis.

user wants four different colors for four countries then.

expression->backgroundcolor->pick(match(country,'india','usa','uk'),red(),green(),blue()). like that

Anonymous
Not applicable
Author

Hey Gysbert,

I am using peek function in my script like

vChart=Peek('Max',0,'Table');

When I am viewing the list of Variables in my application , I am not able to find the variable 'vChart'. This is happening with all the 'peek' variables

Not applicable
Author

Go through the Qlikview Reference Manual, you will get enough information in that...

amit_saini
Master III
Master III

Manoj,

Plz follow this link:

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

Thanks,
AS

its_anandrjs

You forget to put Let word before the statement it will be

Let vChart = Peek('Max',0,'Table');

Where in peek syntax

Peek('FieldName' , Location Of Record from that is 0 position, 'Table Name');

Anonymous
Not applicable
Author

I forgot to write 'let' here but had wrote it in my script