Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Taofeekat
Contributor II
Contributor II

Function for getting Next immediate Row value i.e Reverse of Peek() and Previous

I need help in getting the next row value in my newly created column called "Next row" as seen below.

How can i be able to get the next value of the same ID

ID Date TYPE Next Row
45014927561 12/27/2023 103 104
45014927561 12/27/2023 104 103
45014927561 1/8/2024 103 105
45014927561 1/8/2024 105 106
45014927561 1/8/2024 106 103
45014927561 1/8/2024 103  
4501492800 1/9/2024 103  
4501492808 1/10/2024 101 102
4501492808 2/11/2024 102  
4551492756 12/22/2024 101  
4000000000 10/29/2024 103 105
4000000000 10/29/2024 105  
4000000001 10/29/2024 103  
4112000000 10/24/2024 103 105
4112000000 10/24/2024 105 106
4112000000 10/24/2024 106  
       
Labels (5)
1 Solution

Accepted Solutions
Or
MVP
MVP

Probably easiest with two passes. The first with reverse order to get the value, and mark the second row (where we have the value) as not-for-load. Then a second pass in the original order to peek at the "previous" value and mark the matching row.

View solution in original post

6 Replies
Or
MVP
MVP

Assuming this is in the data load, the typical approach for this is reversing the sort order and getting the previous row.

If it's on the front end, you may be able to use Below() or After() as appropriate.

 

Taofeekat
Contributor II
Contributor II
Author

Thank you for your suggestion. 

Now lets say i want to know if Type 101 is immediately followed by type 102, if yes the 2 rows should be excluded from loading. 

ID Date TYPE Status
45014927561 12/27/2023 103 Don't Load
45014927561 12/27/2023 104 Don't Load
45014927561 1/8/2024 103 Don't Load
45014927561 1/8/2024 105 Load
45014927561 1/8/2024 106 Don't Load
45014927561 1/8/2024 103 Load
4501492800 1/9/2024 103 Load
4501492808 1/10/2024 101 Don't Load
4501492808 2/11/2024 102 Don't Load
4551492756 12/22/2024 101 Load
4000000000 10/29/2024 103 Don't Load
4000000000 10/29/2024 105 Load
4000000001 10/29/2024 103 Load
4112000000 10/24/2024 103 Don't Load
4112000000 10/24/2024 105 Don't Load
4112000000 10/24/2024 106 Don't Load
Or
MVP
MVP

Probably easiest with two passes. The first with reverse order to get the value, and mark the second row (where we have the value) as not-for-load. Then a second pass in the original order to peek at the "previous" value and mark the matching row.

Taofeekat
Contributor II
Contributor II
Author

Oooh, So i will do self join?
or save first before redoing it?

I tried something like this but didn't get it

Or
MVP
MVP

Pass1:

Load stuff From Yourtable;

FinalTable:

Noconcatenate Load stuff Resident Pass1;

Drop Table Pass1;

Taofeekat
Contributor II
Contributor II
Author

Thank you so much, you have been so helpful