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

How to use Peek function?

hi,

I do not know peek function ,how to use  that function please explain me with example.about peek function.

                               Thankyou,

Regards:

Madhu.

11 Replies
SunilChauhan
Champion
Champion

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

Returns the contents of the fieldname in the record specified by row in the input 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 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 input table.

peek( 'Sales', -2 )
returns the value of
Sales from the second last record read into the current input 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.

Sunil Chauhan
Not applicable
Author

Not applicable
Author

I use like this   LOAD   Peek(Product,-1)Resident Product; but it does not work. i attached snipping files below this box.peek1.PNG.pngpeek2.PNG.png

SunilChauhan
Champion
Champion

add on extra field and cchange syntax in resident

use

Load Peek('Product','-1',Product) as fieldname,

1 as J

resident  Product;

drop field J;

hope this helps

or

Load Peek('Product','-1') as fieldname,

1 as J

resident  Product;

drop field J;

Sunil Chauhan
Not applicable
Author

Hi,

check out this

Not applicable
Author

DateDepositBalnc
15/06/2005500

18/06/2005

1500
20/06/2005200
21/06/2005600
25/06/2005100

Let suppose you have a table with a field name as DepositBalnc,and Your requirement is to create a new field with available balance by formula available=DepositBalnc+available and initially available is 0,output table is

DateAvailableDepositBalnc
15/06/20050500
18/06/20055001500
20/06/20052000200
21/06/20052200600
25/06/20052800100

now peek() loads the already loaded field value in the table. now the Available field can be created by following Script

If(RowNo() = 1, 0, Peek(Available)+DepositBalnc) as Available,

Hope now you will understand peek() use..

Not applicable
Author

Thank you sunil

Not applicable
Author

peek() function works within the load block if you dont mention the table name.

but out of the load block you have to use table name like

peek(Product,-1,'Product') try this

SunilChauhan
Champion
Champion

please mark it as helpful correct if you got solution

Sunil Chauhan