Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Saving Numbers in Variables

Status
Not open for further replies.

tmozer

Programmer
Sep 11, 2004
66
US
This is probably simple, but nothing I have figured out yet....

I have four locations grouped to total production figures. Namely, received, completed and pending over an inputed length of time. The report properly print the totals for each location. I need to add combined totals at the end of the report. I could re-parse the data to collect and total the data without the location breakdown, but I would rather save and sum the results from each of the four into a combined variable for each of the three to be printed at the bottom of the report.

How do I need to set this up in Crystal Reports 8.5?
 
Why are you thinking of using variables? If you right click on each of the detail fields for completed, received, and pending and insert a summary, do you get the correct totals? If so, when you right click on each, you have the option of checking "grand total", and this would then give you the figures you need.

If inserting summaries doesn't give you the correct results, then you need to share the contents of the formulas or running totals that you used to get your results for completed, received, and pending. Then someone can help you if you need to use variables.

-LB
 
I'm alittle confused (happens a lot!)....

I am working with two tables combined in a "view" (I believe it is called). The tables are exactly alike in structure. When an assignment is completed it is deleted from one table and moved to the other.

Anyway, I want to work off of a date range parameter ({?SDate} and {?EDate}). For four locations and four units (well, actually two locations have four units, one has three and one only has two) I want to count the number of assignments received during the period, the number completed during the period and the number of uncompleted assignments on the last day of the period. I want to print the three numbers together for each Lab Unit with a final reporting of the combined stats for Unit in the whole system.

I can still do all they by grouping and summarizing??
 
You need to provide feedback. How did you get the group totals for location? What database fields are you working with? Are you using formulas? If so, what are the contents of the formulas? It would help to see sample data, too--try laying out your fields in the detail section and then provide a sample of what the results look like.

Getting your totals is probably simple, but right now I would just be guessing without further information.

-LB
 
Actually I am trying to modify a vendor provided report which has everything but the combined totals or (Plan B) to roll my own report. The vendor program does use formulas, such as:

Shared NumberVar PendCnt;
Shared NumberVar CompCnt;
Shared NumberVar RecCnt;

if ({ALL_ASSIGNMENTS.Date Assigned} = {@DDATE}) then //Daily Received
RecCnt := RecCnt + 1;

//Pending, Received, Completed Assignments
if ( (IsNull({ALL_ASSIGNMENTS.Date Completed})) or ({ALL_ASSIGNMENTS.Date Completed} > {@DDATE}) ) and
(Date({ALL_ASSIGNMENTS.Date Assigned}) <= {@DDATE}) then //Daily Pending
(
PendCnt := PendCnt + 1;
)
else //Daily Completed
(
if (Date({ALL_ASSIGNMENTS.Date Completed}) = {@DDATE}) then
CompCnt := CompCnt + 1;
)

I was able to modify the formula (and reuse same) to give me combined received and completed, but I could not get the combined pending......
 
Are you using subreports? Otherwise the variables don't need to be shared (although it won't hurt anything either).

You haven't shown all your formulas. There is a reset formula placed in the group header that looks something like:

Shared NumberVar PendCnt := 0;
Shared NumberVar CompCnt := 0;
Shared NumberVar RecCnt := 0;

And you will also have display formulas that look like:

whileprintingrecords;
shared numbervar PendCnt;

There will be one for each count, and these will be found in the group footer.

Now to get the report level results, you need to add to the accumulation formula (the one you showed), so that there is a second variable for each of pending, completed and received, which is NOT reset in the reset formula, as in:

Shared NumberVar PendCnt;
Shared NumberVar CompCnt;
Shared NumberVar RecCnt;
NumberVar GrPendCnt;
NumberVar GrCompCnt;
NumberVar GrRecCnt;

if ({ALL_ASSIGNMENTS.Date Assigned} = {@DDATE}) then //Daily Received
RecCnt := RecCnt + 1;
GrRecCnt := GrRecCnt + 1;

//Pending, Received, Completed Assignments
if ( (IsNull({ALL_ASSIGNMENTS.Date Completed})) or ({ALL_ASSIGNMENTS.Date Completed} > {@DDATE}) ) and
(Date({ALL_ASSIGNMENTS.Date Assigned}) <= {@DDATE}) then //Daily Pending
(
PendCnt := PendCnt + 1;
GrPendCnt := GrPendCnt + 1;
)
else //Daily Completed
(
if (Date({ALL_ASSIGNMENTS.Date Completed}) = {@DDATE}) then
CompCnt := CompCnt + 1;
GrCompCnt := GrCompCnt + 1;
)

Then create a separate formula for each grand total like the following and place each in the report footer:

whileprintingrecords;
numbervar GrPendCnt; //replace GrPendCnt with GrCompCnt and
//GrRecCnt for other formulas.

If you are not getting the right results for pending, there may be a logic problem related to the dates so that you should then share the contents of the date formulas. In fact, you should always share the contents of formulas when requesting assistance.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top