Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How can I get next row value in a script?

How can I get next row value in a script?

I am new here in the community and need some help. I have QlikView 8.5.
what is the function of the QlikView-script (not in expression
) to get the next row value to a new field?
I would say the opposite of the Previous ().

Here is my example.

Tab1:

load * inline

[Id,Carno,Color

1,20A,Red

2,17C,Green

3,93B,Red

4,61G,White

5,48X,Black

;

Id

Carno

Color

1

20A

Red

2

17C

Green

3

93B

Red

4

61G

White

5

48X

Black

I want to create field NextCarno as below:

Id

Carno

Color

NextCarno

1

20A

Red

17C

2

17C

Green

93B

3

93B

Red

61G

4

61G

White

48X

5

48X

Black

-

Thanks in advance!

1 Solution

Accepted Solutions
nagaiank
Specialist III
Specialist III

Try the following script and it works.

Tab1:

load * inline [

Id,Carno,Color

1,20A,Red

2,17C,Green

3,93B,Red

4,61G,White

5,48X,Black

];

Tab2:

LOAD *,Peek('Carno') as NewField resident Tab1 order by Id desc;

Drop Table Tab1;

View solution in original post

4 Replies
Not applicable
Author

Create a field like previousid with a formula id-1.

Use this field with loading the table with resident to join the existing table.

This is the fastest solution i can suggest you but of course there may be more optimised solutions.

nagaiank
Specialist III
Specialist III

Try the following script and it works.

Tab1:

load * inline [

Id,Carno,Color

1,20A,Red

2,17C,Green

3,93B,Red

4,61G,White

5,48X,Black

];

Tab2:

LOAD *,Peek('Carno') as NewField resident Tab1 order by Id desc;

Drop Table Tab1;

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi,

   Have a look at the attached document.

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
Not applicable
Author

Thank you very much for the answers. you are the best.