Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Get the next value

Hi,

I read a file with the script.

For each record, I created a new field with the previous value :

Previous( myField ) as Prev_Field

My question is how to create another field with the next value ?

I tried Fieldvalue ( 'myField' , recno() + 1) but without success. Any ideas ? Of course my file is well-sorted.

Thanks very much for your help.

Jean-Jacques

3 Replies
Not applicable
Author

Hi Jean-Jacques

Did you experiment with lookup? As you have the Prev_Field in your loaded table it should be something like

lookup('myField', 'Prev_Field', Prev_Field_Value)

Jürg

Not applicable
Author

Please see below an example of getting next value:


Tab1:
load * inline [
col1,col2,recordno
A,20,1
B,30,2
C,40,3
A,50,4
];
let v = peek('recordno');
for i = 1 to $(v)
let v = lookup('col2','recordno',$(i)+1,'Tab1');
Tab2:
load
recordno,
col1,
col2,
Previous(col2) as prev,
if(isnull('$(v)'),null(),$(v)) as next
resident Tab1
where recordno = $(i);
next
drop table Tab1;


Not applicable
Author

Thanks guys for your quick answers.

JJ