Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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;
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.
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;
Hi,
Have a look at the attached document.
Regards,
Kaushik Solanki
Thank you very much for the answers. you are the best.