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

How to get the 2nd nearest date without using Max(Date,2)?

Dear all,

Just have a question to get the 2nd nearest date without using Max(Date,2).

Currently, I use the following syntax to get Sum(Shares) on the nearest date, and it woks fine.

Sum(Aggr(Sum({$< Report_Date={"$(     =Max(Report_Date)     )"} >} Shares), Security_ID) )

However, when I tried to get the 2nd nearest date without using Max(Date,2) for some concerns, I used the following syntax

Max({<  Report_Date={     "<=$(=Date(Max(Report_Date)-1,'YYYY/MM/DD'))"     } >} Report_Date)

to replace

Max(Report_Date)

But it didn't work, is anyting wrong here?

It's appreciated if someone can help me out here.

13 Replies
Anonymous
Not applicable
Author

The data format should be same as Access format as "yyyy/m/d".

Anonymous
Not applicable
Author

Just an aside, but I never knew max()  had a rank parameter.

- Thanks for enlightening me.

Anonymous
Not applicable
Author

Thanks, it works well in char.

Anonymous
Not applicable
Author

Thanks for the lines, just realised the error may be caused by "".

However, I didn't succeed by using the line above, but it works OK with the following lines,

but I have no idea why it works.

Sum(Aggr(Sum({$< Report_Date={"$(=Max({<Report_Date={'<$(=Max(Report_Date))'}>} Report_Date))"} >} Shares)

, Security_ID) )