Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
LINKEDIN LIVE: Democratizing data to enhance customer-centricity. JULY 29TH REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
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

6 Replies
santiago_respane
Specialist
Specialist

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
Author

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

settu_periasamy

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
Partner
Partner

Yes your assumption is right.

Both will be working on top of loaded tables.

santiago_respane
Specialist
Specialist

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,

Charles_Alter-SI
Contributor II
Contributor II

Hello,

 

I had the issue with log ordered by date (I wanted to compare the timestamp to the next). I find a simple solution was to order the table by Date desc;

 

Fait :
NoConcatenate
Load
Flg_TP,

id_objet,
if(Previous(id_objet)=id_objet, Previous(Date_et_heure)-Date_et_heure,0) as Duration,
Date_et_heure
Resident Fait_tmp order by id_objet,Date_et_heure desc;