Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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
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,
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,
Thank you very much for your help.
Best,
Parth
Hi Parth,
For 2nd Point,
The data for the Peek() function is loaded from the previously loaded table in the associative QlikView database.
Yes your assumption is right.
Both will be working on top of loaded tables.
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,
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;