Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: NthLargest script not working Post Reply Post New Topic
Author Message
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet Topic: NthLargest script not working
    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
 
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet 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.
 


Edited by Emir_W - 06 Jul 2010 at 4:25pm
Emir W
IP IP Logged
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet 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

IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 06 Jul 2010 at 4:26pm
yes, you can try that
 
 
Emir W
IP IP Logged
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet 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


Edited by keithrichards - 06 Jul 2010 at 4:49pm
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet 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
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet 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.
 
 


Edited by Emir_W - 09 Jul 2010 at 9:05pm
Emir W
IP IP Logged
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet 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
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.031 seconds.