Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
suzel404
Creator
Creator

How to display the previous and Next records


Hi all,

Is there an other method to display the previous and Next records

I create the previous BasePrice ans NextBase Price.

LOAD
ID,
BasePrice,
TotalAmount
FROM GetPreviousField.xls (biff, embedded labels, table is Sheet1$);



LEFT JOIN LOAD
*,
 
peek(BasePrice) AS NextBasePrice
RESIDENT Data ORDER BY ID DESC;

LEFT JOIN LOAD
*,
peek(BasePrice) AS PreviousBasePrice
RESIDENT Data ORDER BY ID ASC;

1 Solution

Accepted Solutions
swuehl
MVP
MVP

I think your basic approach using peek() and ordered input tables is fine.

Instead of the joins, you can use (and I would recommend that) ordinary LOADs, like

Data:

LOAD
ID,
BasePrice,
TotalAmount
FROM GetPreviousField.xls (biff, embedded labels, table is Sheet1$);

TMP:
LOAD
*,
 
peek(BasePrice) AS NextBasePrice
RESIDENT Data ORDER BY ID DESC;


RESULT:
LOAD
*,
peek(BasePrice) AS PreviousBasePrice
RESIDENT TMP ORDER BY ID ASC;


DROP TABLES Data, TMP;

View solution in original post

4 Replies
swuehl
MVP
MVP

I think your basic approach using peek() and ordered input tables is fine.

Instead of the joins, you can use (and I would recommend that) ordinary LOADs, like

Data:

LOAD
ID,
BasePrice,
TotalAmount
FROM GetPreviousField.xls (biff, embedded labels, table is Sheet1$);

TMP:
LOAD
*,
 
peek(BasePrice) AS NextBasePrice
RESIDENT Data ORDER BY ID DESC;


RESULT:
LOAD
*,
peek(BasePrice) AS PreviousBasePrice
RESIDENT TMP ORDER BY ID ASC;


DROP TABLES Data, TMP;

sukydhak
Partner - Contributor III
Partner - Contributor III

I think Previous may also be an option but Peek should work. 

suzel404
Creator
Creator
Author

Thank you Suky.

suzel404
Creator
Creator
Author

Hi Swuehl,

Your approach is interesting, thank you.