Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
Not applicable

Look at the previous value and next value of the row

Hello experts,

I am currently working on a problem in which I want to look at the previous value of the row and which I can achieve by using Peek function. How can I look at the next value at the same time?

I want to be able to look at both at the same time. Please let me know if you need any more information. Greatly appreciate your help.

Thank you,

Parth

5 Replies
santiago_respane
Valued Contributor

Re: Look at the previous value and next value of the row

Hi Path,

you can achieve this using the Peek function using its parameters like this:

peek( 'Sales',-1 )  - returns the value of Sales in the previous record read ( equivalent to previous(Sales) ).

peek( 'Sales', 1 ) - returns the value of Sales from the second record read from the current internal table.

Hope this helps.

Kind regards,

Not applicable

Re: Look at the previous value and next value of the row

Hi Santiago,

Thank you for your response.

I m confused now. Would you please verify my two statements below?

If I am at row 1000,

  1. Peek('Sales',-1) --> does it look at row 999?
  2. Peek('Sales',1) --> does it look at row 1001?

Thank you very much for your help.

Best,

Parth

Re: Look at the previous value and next value of the row

Hi Parth,

For 2nd Point,

The data for the Peek() function is loaded from the previously loaded table in the associative QlikView database.


Peek() or Previous() ?

krishnacbe
Valued Contributor III

Re: Look at the previous value and next value of the row

Yes your assumption is right.

Both will be working on top of loaded tables.

santiago_respane
Valued Contributor

Re: Look at the previous value and next value of the row

Here you have an example:

TABLE_AUX:

load * inline [

  a,b

  r,1

  s,2

  t,3

  u,4

  x,5

  y,6

  z,7

];

TABLE_FINAL:

LOAD

  a,  b,

  PREVIOUS(b) as PREV,

  PEEK('b',RowNo(),'TABLE_AUX') as NEXT

RESIDENT TABLE_AUX;

DROP TABLE TABLE_AUX;

Please tell if this suits your needs.

Kind regards,

Community Browser