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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to find previous and next record from a table?

Hi....

Suppose I have a tbale with dates..

Date
01/01/2011
01/01/2011
01/01/2011
5/05/2011
8/8/2011
8/8/2011
10/10/2011

I want a table with following columns...

DatePrevious DateNext Date
01/01/2011-01/01/2011
01/01/201101/01/201101/01/2011
01/01/201101/01/20115/01/2011
5/05/201101/01/20118/8/2011
8/8/20115/05/20118/8/2011
8/8/20118/8/201110/10/2011
10/10/20118/8/2011-

I want Previous and next record of each rows.

Thanks in advance...

Satish

4 Replies
swuehl
MVP
MVP

I think you can use the interrecord functions: above and below:

=above(Date)

resp.

=below(Date)

as expressions for Previous Date and Next Date with dimension Date.

Regards,

Stefan

Not applicable
Author

I have to use those Previous Date and Next Date fields in Some calculations.

So I need those fields only in script part. I also used Previous and peek functions.

But value I am getting is not right.

Regards,

Satish.

its_anandrjs
Champion III
Champion III

Hi,


Yes right you need to use the Above and Below fuctions for the date view for the Previous Date and Next Date put Above(Date) , Below(Date).

See the attached sample for clearing your problems.

Regards

Anand

swuehl
MVP
MVP

If you want to create that table in script, you might use something like:

Left Join Load *,

peek(Date) as NextDate

resident Dates order by Date desc;

Left Join Load *,

peek(Date) as PreviousDate

resident Dates order by Date ASC;

Where Dates is your calendar table with field Date.