Skip to main content
Announcements
See why Qlik is a Leader in the 2024 Gartner® Magic Quadrant™ for Analytics & BI Platforms. Download Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to get last but one Date from a field with out manually entering the date?

I have a list dates in field.The list of dates changes all the time.I want to automatically pick last but one date from the list.I want to use that last but one date in an expression.

From:

Sale Date

12/24/2011

01/03/2012

06/04/2012

I want to pick the last but one date 01/03/2012 in this example instead of writing as Sale Date='01/03/2012'

Thanks

6 Replies
Not applicable
Author

Hi cnpcon04,

I guess you need the second highest value?

Try this:

max([Sale Date],2)

alexandros17
Partner - Champion III
Partner - Champion III

Try this

=max({$ <date={'<$(=max({1} date))'}>} date)  

hope it helps

Not applicable
Author

No.I want to get the last but one irrespective of its value.

Thanks for the reply

Not applicable
Author

Thanks for the reply.It did not work.

alexandros17
Partner - Champion III
Partner - Champion III

I tried this with a

load

* inline

[

k,v

A,1

B,2

C,3

D,4

E,5

]
;

obviously substituting date with v and I put the expression in a text box (you can use a variable) and I'm sure it works ... the problem with dates can be the formatting!

manideep78
Partner - Specialist
Partner - Specialist

Try peek() function

LET vLastDate = peek('Field_Name',-2,'Table_Name')

-2 specifies the last but one record