Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Find the next date prior to the currently selected date

I have a series of dates, eg.:

  • 20160628
  • 20160627
  • 20160623
  • 20160620

If I select a particular date, I want to find the date immediately prior to that date.

For example:

  • If I select 20160628, I get 20160627. 
  • If I select 20160627, I get 20160623.
  • If I select 20160623, I get 20160620.

Obviously, "Date - 1" won't work.  Is there a way to do this in QlikView?

1 Solution

Accepted Solutions
antoniotiman
Master III
Master III

Try

=Max({<Date={'<$(=Max(Date))'}>} Date)

View solution in original post

5 Replies
MK_QSL
MVP
MVP

You need to create DateID for this..

SET DateFormat='YYYYMMDD';

SET TimestampFormat='YYYYMMDD hh:mm:ss[.fff]';

Data:

Load * Inline

[

DateField

20160628

20160627

20160623

20160620

];

Left Join (Data)

Load Distinct DateField, AutoNumber(DateField) as DateID Resident Data

Order By DateField;

Now use below...

=Max({<DateField, DateID = {'$(=Max(DateID)-1)'}>}DateField)

Anonymous
Not applicable
Author

Hi

use Below() or Above() function

like Below(dates) ?                           **Below(yourdatefield)

antoniotiman
Master III
Master III

Try

=Max({<Date={'<$(=Max(Date))'}>} Date)

MK_QSL
MVP
MVP

Excellent !

antoniotiman
Master III
Master III

Thanks Manish.

Regards,

Antonio