• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 497
  • Last Modified:

Grand Total of a calculation from a subreport

I have a report that has Orders and Lines. It has a sub report that has dollars that are tied to the order but not to a line.

I total all the lines up and get a subtotal and then add the Misc charges from the subreport using a shared number variable. Now I would like to add these up to get a total for all the orders for a customer. When I try to sum it tell me I can't summarize this field (the shared variable).

I also can't find the field to do a running total on it.
 
Here is the code where I share the variable

//@MainSubSell
//Returns the value that was stored
//in the shared Number variable called
//mySubSellTotal in the subreport

WhilePrintRecords;
Shared NumberVar mySubSellTotal;
mySubSellTotal

//@SubSellTotal
//Returns the sum of the misc sell from
//{OP_MISCCHAR.Sell} field
//in a numbervar called 'mySubSellTotal'

WhilePrintingRecords;
Shared NumberVar mySubSelltotal := ToNumber(Sum({OP_MISCCHAR.Sell}))

Any help would be appreciated.

Thanks,
james
0
James Stone
Asked:
James Stone
1 Solution
 
frodomanCommented:
You can't summarize a formula that is evaluated during the WhilePrintingRecords step.  The easiest approach would be to simply add a variable for your customer total.

In @SubSellTotal change the formula to read like this:
WhilePrintingRecords;
Shared NumberVar mySubSelltotal;
Shared NumberVar myCustomerTotal;
mySubSelltotal := ToNumber(Sum({OP_MISCCHAR.Sell}));
myCustomerTotal := myCustomerTotal + mySubSelltotal;


You probably understand from there - add a formula in the Customer group header to reset myCustomerTotal := 0 between customers and in the Customer footer show the result normally.  I can explain further if you need any more details.
0
 
James Stonewarehouse managerAuthor Commented:
I got it! Thanks for the tip!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now