Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

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

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
Valued Contributor III

Re: How can I get next row value in a script?

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;

4 Replies
Not applicable

How can I get next row value in a script?

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
Valued Contributor III

Re: How can I get next row value in a script?

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;

Re: How can I get next row value in a script?

Hi,

   Have a look at the attached document.

Regards,

Kaushik Solanki

Not applicable

How can I get next row value in a script?

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

Community Browser