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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help on how to sum a Field Object?

Status
Not open for further replies.

Hoopper

Programmer
Apr 24, 2006
6
US
I am trying to obtain the sum of a field object, @TotalValue, but have been running into some problems.

My report contains one group only:
i) Group header is blank.
ii) Details section is suppressed.
iii) Group footer shows fields, sum of
Job_Progress.QTYREM_14, @LaborTime, @LaborUnitCost,
and @TotalValue.
iv) Report footer shows sum of Job_Progress.QTYREM_14,
which is the sum of sum of Job_Progress.QTYREM_14
found on the group footer, and this is actually
correct.

@TotalValue = sum of Job_Progress.QTYREM_14 * @LaborUnitCost, and this is correct also.

Now, I am trying to obtain the sum of @TotalValue and I would like to place this sum in the report footer. The sum function doesn't seem to be able to get it done;
sum({@TotalValue}) -- error message is "the sum could not be created".

Please any suggestions?


 
Depends on what;s in the formula, and since you didn't share it's contents, here's a generic solution.

Within the @TotalValue formula add in a variable, as in:

whileprintingrecords;
numbervar TotSum;
TotSum:=TotSum+<whatever is currently being done in there>

Now in the report footer place:

whileprintingrecords;
numbervar TotSum

-k
 
K:

Thanks for the tip but I am still unable to resolve this issue as I am new to Crystal syntax. I am not sure how to correctly add your tip within the @TotalValue formula context.

@TotalValue is calculated as follows:

select {Job_Progress.OPRSEQ_14}
case "200":
1 * 1.83 * Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) + (Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) * 15)
case "210":
1 * 1.83 * Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) + (Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) * 15)
case "220":
(1 + 6.67) * 1.83 * Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) + (Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) * 15)
case "231":
(1 + 6.67 + 3.33) * 1.83 * Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) + (Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) * 15)
case "241":
(1 + 6.67 + 3.33 + 1) * 1.83 * Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) + (Sum ({Job_Progress.QTYREM_14}, {Job_Progress.OPRSEQ_14}) * 15)

As shown above, @TotalValue uses the select structure. There are 12 more cases before the "default case" which are not shown here due to size, but they all maintain the same incrementing format.

Thanks in advance for your time and efforts.

B
 
Well you might convert to an IF here, but in either case, you can use an additional formula to resolve:

EvaluateAfter (@TotalValue);
numbervar TotSum:=TotSum+@TotalValue

Place this formula in the group footer.

Then use a display formula in the report footer as in the previous post.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top