Report Design
 Crystal Reports Forum : Crystal Reports for Visual Studio 2005 and Newer : Report Design
Message Icon Topic: Increment a number on max date 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: Increment a number on max date
    Posted: 03 Jul 2010 at 6:25pm

Hi all,

 

I have the follow script which increments by 1 each time a particular vehicle has been into the service department after the specified date. If the same vehicle has been in twice after this date I still only want to count it once. Hence I am trying to count the max date. At the moment my script counts each instance the vehicle has been in.

 
Not sure if I am using the correct logic construct, but the existing script below nearly gives me what I need.

 

Existing Script

 

WhilePrintingRecords;
NumberVar CountService;
NumberVar CountReport;
If maximum ({service_Date},{Vehicle_Number}) > Date (2010, 06, 07) then
(CountService := CountRO + 1;
CountReport := CountReport + 1)

 

A snapshot of the current result looks like the following,

 

Service Date            Vehicle Number                  Count Service

19.04.2010              6FPAAAJG517840                        1

11.06.2010              6FPAAAJG517840                        2

24.08.2010              ABC12345891111                         3

 

What I am trying to achieve

 

Service Date            Vehicle Number                  Count Service
19.04.2010              6FPAAAJG517840                        0
11.06.2010              6FPAAAJG517840                        1

24.08.2010              ABC12345891111                          2

 
Any assistance would be GREATLY appreciated.
 
Thanks KR


Edited by keithrichards - 03 Jul 2010 at 11:36pm
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 06 Jul 2010 at 3:52am

WhilePrintingRecords;
NumberVar CountService;
NumberVar CountReport;
If maximum ({service_Date},{Vehicle_Number}) > Date (2010, 06, 07)  AND  maximum ({service_Date},{Vehicle_Number})  ={service_Date} then
(CountService := CountRO + 1;
CountReport := CountReport + 1)

 
HTH
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:13pm
Thanks for your help,
 
Stretching the friendship on another note, I'm using the NthLargest function in the script below and it is not working properly.
 
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
 
Any suggestions would be appreciated.
 
Many thanks,
 
KR
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 07 Jul 2010 at 3:18am

Sorry, never used NthLargest...you want to select 4/5/09?  That is what the code would seem to do. 

sorry can't be of more help
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.016 seconds.