Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Vehicle Service Query 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: Vehicle Service Query
     Posted: 30 Jun 2010 at 3:45pm

Hi all,

 

I have two tables, vehicle and vehicle service. I want to know which vehicles have been into the service department. The vehicle table is linked to the service table via a ”VIN_number”. There are about 5000 vehicles in the vehicle table and each service can be identified by an RO_Number.

 

All I really want is a list of the 5000 vehicles and a yes or no if they have been in for a service.

 

My problem at the moment is because a vehicle may have been into the service department multiple times, my report is listing the vehicle and each RO_Number relating to it. This gives me a list of about 15,000 instances of the vehicles.

 

I only want to identify if the vehicle has been into the service department and not how many times.

 

I have tried adjusting table joins and currently the vehicle table is connected to the service table via a Left Outer Join, Not enforced with an = link type. As an option to narrow down the numbers I tried adjusting the running total evaluate and reset field options without luck.

 

Ideally I would like a formula field that only returns the Max RO_Number for each VIN_Number.... but at this stage I have not had any luck... hence this call for help.

 

Can anyone suggest how my resolve this.

 

Thanks,

 

KR

IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 01 Jul 2010 at 7:12am
Not sure if this is the best solution but it should work.

Great a group based on the Vin_number field.

Create formula1 (place in group header)

count({table.RO_Number},{table.Vin_Number})

If needed create a second formula

if {@formula1}=0 then "No" else "Yes"

Suppress the details section within the report.

Hope this helps.


IP IP Logged
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet Posted: 01 Jul 2010 at 4:33pm
Thanks for you reply!
 
This nearly gives me what I need. My only issue now is being able to count the number of Yes and no's in the second formula.
 
I tried this using a running total but the formula field is not visible for selection in the running total wizard. Any suggestions?
 
Thanks,
 
KR
IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 02 Jul 2010 at 1:01am
You may need to play with it a bit - but something along these lines should work

evaluateafter({@formula2});
numbervar test;

if {@formula2}="yes" then

(test := test +1); test

IP IP Logged
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet Posted: 04 Jul 2010 at 1:19am

Thanks for that. I REALLY appreciate your help so far.

 

My criteria changed slightly in that I decided I needed to count the number of times the vehicle has been in as opposed to the yes or no in my previous post.

 

I now have the following script which increments by 1 each time a particular vehicle has been into the service department after the specified date.

 

One more issue to fix now is that if the same vehicle has been in twice after the specified date I only want to count it once. At the moment my script counts each and every instance the vehicle has been in. Hence I am trying to count by the max date. 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 ({RO_Date},{VIN_Number}) > Date (2010, 06, 07) then

(CountService := CountService + 1;

CountReport := CountReport + 1)

 

A snapshot of the current result looks like the following,

 

RO Date                  VIN Number                      Count Service

19.04.2010              6FPAAAJG517840                        1

11.06.2010              6FPAAAJG517840                        2

24.08.2010              ABC12345891111                        3

 

What I am trying to achieve

 

RO Date                  VIN Number                      Count Service

19.04.2010              6FPAAAJG517840                        0

11.06.2010              6FPAAAJG517840                        1

24.08.2010              ABC12345891111                        2

 
Thanks again,
 
KR
IP IP Logged
keithrichards
Newbie
Newbie


Joined: 30 Jun 2010
Location: Australia
Online Status: Offline
Posts: 31
Quote keithrichards Replybullet Posted: 04 Jul 2010 at 3:20pm

Hi all,

Just a quick post to communicate how I got around the problem.
 
I created a formula field using the NthLargest function. NthLargest(1, {RO_DATE},{VIN_NUMBER}) and inserted into the group. This gave me a result of only the last date. I then had a second formula in the group that only counted those dates that met my criteria.
 
WhilePrintingRecords;
NumberVar CountRO;
NumberVar CountReport;
If {@ROCalc} in {?Start RO_DATE} to {?End RO_DATE} then
(CountRO := CountRO + 1;
CountReport := CountReport + 1)
 
Thanks again,
 
KR
IP IP Logged
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