Okay... a bit of a story here but I think knowing the full background will help... I've been asked to generate a report that shows the estimated and actual setup and run times for a number of machines. The SQL generated By CrystalReports to access the data is this:
SELECT "order_details"."order_id", "order_details"."order_line_nbr", "order_details"."docket_id", "track"."process_nme", "order_details"."order_qty", "order_routing"."setup_time", "order_routing"."run_speed", "track"."process_qty", "track"."start_date", "track"."setup_min", "track"."run_min"
FROM ("oboe_data"."dbo"."order_details" "order_details" INNER JOIN "oboe_data"."dbo"."order_routing" "order_routing" ON ("order_details"."order_id"="order_routing"."order_id") AND ("order_details"."order_line_nbr"="order_routing"."order_line_nbr")) INNER JOIN "oboe_data"."dbo"."track" "track" ON (("order_details"."order_id"="track"."order_id") AND ("order_details"."order_line_nbr"="track"."order_line_nbr")) AND ("order_routing"."process_id"="track"."process_id")
ORDER BY "track"."process_nme", "track"."start_date"
The resultant report is done in CrysRep grouped by process_nme and sorted within the group by start-date. Works fine... except if a given order is listed more than once in the group (due to the job spilling over shifts for instance) it will list the estimated setup time each time in the report. See below for a snippet which illustrates this.
| OrderID |
start_date |
Dock # |
Order_Qty |
Est Setup |
| STITCHER |
|
|
|
|
| 56400-45 |
2/2/09
7:09 AM |
126259 |
500 |
10 |
| 56800-00 |
2/2/09
8:27 AM |
105442 |
1,000 |
10 |
| 56573-40 |
2/2/09
9:50 AM |
135056 |
3,000 |
10 |
| 56744-10 |
2/2/09
12:27 PM |
202680 |
80 |
10 |
| 56744-10 |
2/2/09
12:45 PM |
202680 |
80 |
10 |
| 56035-10 |
2/2/09
1:18 PM |
108971 |
450 |
10 |
| 58045-10 |
2/2/09
2:56 PM |
108971 |
450 |
10 |
| 57095-20 |
2/2/09
2:57 PM |
108971 |
450 |
10 |
As you can see in the example, 56744-10 is listed twice and has set-up times present for both; I'd rather it set this value to zero for all subsequent instances. What I thought to do (after reading a suggestion earlier in this forum) was to use PreviousValue to check to see if OrderID was the same as the line above. So I used this for the formula called SetupCheck:
if {order_details.order_id} <> Previous({order_details.order_id}) then
{order_routing.setup_time}
else
0;
Problem fixed... except I now have two new problems which I'm now stuck on. The first is that it won't let me select formula in order to create a summary for the group based on the formula... I have checked and the result does seem to be a number.
The second problem is that for the very first line on the report, the value for SetupCheck is blank. Not zero, not the setup time value, it's blank. It shouldn't be.
Any ideas on what's going on and how I can get my report to come out as
I want it to look?
Edited by JCrowhurst - 04 Feb 2009 at 11:43am