Print Page | Close Window

NthLargest script not working

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=10445
Printed Date: 03 May 2024 at 4:25pm


Topic: NthLargest script not working
Posted By: keithrichards
Subject: NthLargest script not working
Date Posted: 06 Jul 2010 at 3:51pm
Hi there,
 
Can anyone suggest why this script is not working.
 
If {RO_DATE}  in Date (2008, 08, 01) to Date (2009, 07, 31) then
NthLargest(1, {RO_DATE},{vehicle_VIN})
 
I am trying to select the highest date where the date falls into the specified date range. Eg based on the above script and the dates below, I would want it to throw out out 04/05/2009.
 
11/03/2008
04/11/2008
04/05/2009
24/11/2009
21/05/2010
 
Many Thanks,
 
KR
 



Replies:
Posted By: Emir_W
Date Posted: 06 Jul 2010 at 4:17pm
if {tbl.field} >=date(2008,08,01) and {tbl.field}<=date(2009,07,31) then
   NthLargest(1,{tbl.datefield},{tbl.vehiclefield})
 
 
 
 
hope it help.
 


-------------
Emir W


Posted By: keithrichards
Date Posted: 06 Jul 2010 at 4:24pm

Thanks forthe reply,

Are you saying that the script should be something like this,
 

if {RO_DATE} >=date(2008,08,01) and {RO_DATE}<=date(2009,07,31) then

  

NthLargest(1, {RO_DATE},{vehicle_VIN})

 

Else

 

  0

Thanks again,

KR



Posted By: Emir_W
Date Posted: 06 Jul 2010 at 4:26pm
yes, you can try that
 
 


-------------
Emir W


Posted By: keithrichards
Date Posted: 06 Jul 2010 at 4:47pm
Hi there,
 
I tried that and unfortunately it is still not working...
 
 
If {RO_DATE} >= Date (2008, 08, 01) and {RO_DATE} <= Date (2009, 07, 31) then
NthLargest(1, {service_retention1.RO_DATE},{vehicle_VIN})
Else Date (1900, 01, 01)
 
It actually threw out the date 01, 01, 1900.
 
Maybe the date criteria needs to be wrapped within the NthLargest brackets... but I tried that as well with no luck as yet.
 
Thanks again,
 
KR


Posted By: Emir_W
Date Posted: 06 Jul 2010 at 5:10pm
did you grouped by {tbl.vehicle_vin} ??
 
NthLargest (N, fld, condFld) where:
  • N is any integer from 1 to 100 (inclusive).
  • fld is any valid database or formula field that can be evaluated by the function.
  • condFld is a field used to group the values in fld by.

and  for 'else' condition should be same format.

 
hope it help.
 
 


-------------
Emir W


Posted By: Emir_W
Date Posted: 09 Jul 2010 at 9:03pm
you can change the formula by removing the last params.
so, it will be:
NthLargest(1,{tbl.Ro_Date})
 
it will take only 1 largest date from RO_Date.
 
 
 
hope it help.
 
 


-------------
Emir W


Posted By: keithrichards
Date Posted: 10 Jul 2010 at 1:39am
Thanks,
 
I'm using the following formula as one of the steps to deliver what I need and I have now resolved the issue.... YAH!
 
 
NthLargest(1,{@RoDate},{vehicle_VIN})
 
Thanks again,
 
KR



Print Page | Close Window