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.
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.
Date DepositBalnc 15/06/2005 500
1500 20/06/2005 200 21/06/2005 600 25/06/2005 100
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
Date Available DepositBalnc 15/06/2005 0 500 18/06/2005 500 1500 20/06/2005 2000 200 21/06/2005 2200 600 25/06/2005 2800 100
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..
Peek function returns the value of the previous record read.
For eg; In the output below,
- Name and Value are my source columns
- Expression for the other two:
Peek('Value') as Peek_Value
– Stores the previous record value (this is same as Previous function)
Peek('Value',1) as Peek_Value_1
– Qlikview internally assigns values starting from ‘0’ ( ‘0’for the first row/record, ‘1’ for the second row and so on).
So, if we set the value as ‘1’. It reads the value at 2nd row and starts assigning the same value from 3rd row
Name Value Peek_Value Peek_Value_1 A 1 - - B 2 1 - C 3 2 2 D 4 3 2 E 5 4 2 F 6 5 2
For More clarity & real time example, Please take a look at the document on
Hope this helps!!