crystal reports - summarise a formula field

RichardH1976
RichardH1976 used Ask the Experts™
on
I have picked up a report off someone who has left the company.  He has built the report with subreports to calculate a total and then a formula field to summarise each total.   The formula field is in a group footer to give a total by country.

I cannot summarise a formula field so have tried to calculate with variables.   the formula field is territoryordered.

So far I have in the report header.
(
WhilePrintingRecords;
Global NumberVar GTotal;

in the group header where the formula field is;
WhilePrintingRecords;
Global NumberVar GTotal;
GTotal:=GTotal+{@TerritoryOrdered};
GTotal

This is giving me the wrong total.  I would like to display the total in the report footer but I cannot get the correct amount to display in the group header.

Sorry I bet this is simple...   Richard
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet Software

Commented:
Place {@TerritoryOrdered} in the group header.  Does it show the value you expect?  If not, look inside that formula to figure out the problem.  
Note: if that main report formula is grabbing a value from a subreport placed in the same group header, you must move that formula to a section BELOW the subreport section. For example, place the formula in GF1 or GH1b if the subreport is in GH1a.  This is because, within a section, formulas are evaluated before subreports.
Mike McCrackenSenior Consultant
Most Valuable Expert 2011
Top Expert 2013

Commented:
What is the @TerritoryOrdered formula?

As written the value in the group header will be  "running" total for the report to that point.

Are you trying to get the total of the formula for the group?

mlmcc

Author

Commented:
The @territoryordered is a variable that adds all variables totals up which are in sub reports,  these are all in group headers.  1a, 2a, 3a etc...  There are 10 different territories and I get sub totals for each one.   I need to grand total the territory ordered formula field.
Senior Consultant
Most Valuable Expert 2011
Top Expert 2013
Commented:
Change your formula in the Group Header to
EvaluateAfter({@TerritoryOrdered});
 Global NumberVar GTotal;
 GTotal:=GTotal+ {@TerritoryOrdered};
""

Open in new window


IN the report footer
WhilePrintingRecords;
Global NumberVar GTotal;
 GTotal

Open in new window


mlmcc

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial