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

Summing a formula field 1

Status
Not open for further replies.

amberlynn

Programmer
Dec 18, 2003
502
CA
Hello,
I'm unable to do something that should be simple...
I'm using CR XI.

In my report I have 3 columns (A, B, C). C is a formula (C=A*B). In the group footer, I want to sum C - but I can't.
I get the message "This field cannot be summarized".

How else can I do this??

Thanks!
Amber
 
I probably should clarify, My fields are in the group footer, and I'm trying to create a 'summing' formula in the report footer.
 
What are A and B? If they really were fields, you would be able to summarize by inserting a summary on C--as long as C doesn't use any variables--and there shouldn't be a need to. Please show the contents of A, B, and C.

-LB
 
A is a formula (the sum of a bunch of shared variables from elsewhere in the report. B is a field. C is A*B.

Amber
 
You will have to use a variable to sum C. Create a formula {@accum} to be placed in the section where you are calculating C:

whileprintingrecords;
numbervar sumC := sumC + {@C};

Then create a display formula:

whileprintingrecords;
numbervar sumC;

Place this in the report footer.

If you want to sum at the group level, then you will need a reset formula for the group header:

whileprintingrecords;
numbervar sumC := 0;

If you want both group and report totals, then you need to add another variable for the report total with no reset formula.

For more help, you should provide your group structure and indicate where the subreports and your formulas are located, and also provide the contents of the formulas.

-LB
 
OK, here's a tougher one :)

I have a formula called @total that looks like:

Shared numberVar FallingTotCost + Shared numberVar SkiddingTotCost + Shared numberVar LoadingTotCost + Shared numberVar ProcessingTotCost + Shared numberVar LowBedTotCost + Shared numberVar TotalFixed + {#RTotal};

which pulls shared variables from all over my report.
This field is in the group footer.
I need to average this number in the form footer.
I can't average @total ('this field cannot be summarized').

How can I make this work??

Thanks!
Amber
 
If this formula is currently giving you the correct value, then rewrite the formula (written in the more accepted format) and add variables as follows:

whileprintingrecords;
Shared numberVar FallingTotCost;
Shared numberVar SkiddingTotCost;
Shared numberVar LoadingTotCost;
Shared numberVar ProcessingTotCost;
Shared numberVar LowBedTotCost;
Shared numberVar TotalFixed;
Numbervar costs := FallingTotCost + SkiddingTotCost + LoadingTotCost + ProcessingTotCost + LowBedTotCost + TotalFixed + {#RTotal};
Numbervar sumcosts := sumcosts + costs;
Numbervar cnt := cnt + 1;
costs;

Without knowing the group structure of your report, I don't know what "form footer" refers to. If this is a an outer group footer, then you need a reset formula in the form group header:

whileprintingrecords;
numbervar sumcosts;
numbervar cnt;
if not inrepeatedgroupheader then
(
sumcosts := 0;
cnt := 0
);

In the form group footer, add the following formula to get the average:

whileprintingrecords;
numbervar sumcosts;
numbervar cnt;
sumcosts/cnt;

If this does not work correctly, please provide the earlier requested information: your group structure with group fields identified, the location of your subreports, identification of the shared variable formulas within the subreports, and also the contents of formulas.

-LB
 
Worked great!
I left out the group header formula (or my average was reset).
Thanks!!
Amber
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top