Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP 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

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.