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

Sum A Formula Field 1

Status
Not open for further replies.

BadPenguin

Programmer
Nov 5, 2004
11
US
I am running Crystal for Visual Studio.Net.

I need to sum a formula for an entire report. The field is just calculating the discount of an order and it looks something like this:

if left({discount},1) = "$" then tonumber(mid({discount},2)) else
if left({discount},1) = "%" then tonumber(mid({discount},2))/100*Sum ({@order}, {orderNumber})

Thanks in advance
 
First check to see if it will let you create a running total for the formula field. Right-click and choose Insert to get a choice of Running Total, Summary and Grand Total. Or else use the Field Explorer, the icon that is a grid-like box.

It helps to give your Crystal version, since newer versions have extra options, and some extra problems. I use Crystal 8.5.

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
The reason you cannot create a summary off of the posted formula is that it already contains a summary function. Crystal will not allow you to create a sum of another sum.

I suggest that you look at Running Totals as Madawc has suggested, or even creating formulas and variables to manually accumulate the totals.

~Brian
 
I am using Crystal for VS.Net 2003. Beyond that, I cannot tell you the version number.

It wont let me create a running total for it. I am not sure how to go about redesigning the report to get around this.
 
You need to use a variable. If you want a grand total, create two formulas:

//{@accum} to be placed in whatever section your formula is:
whileprintingrecords;
numbervar grtot := grtot + {@yourformula};

//{@display} to be place in the report footer:
whileprintingrecords;
numbervar grtot;

If you need the results as a group level, you would create a variable with a reset:

//{@reset} to be placed in the group header:
whileprintingrecords;
numbervar grtot := 0;

//although the variable name no longer makes sense here!

-LB
 
OK, this is perfect, but one thing. Is there anyway I can display this in the report header?
 
You would need to save the report as a subreport and then insert the subreport in the report header of the original report. In the subreport, you would suppress all but the section in which {@display} is shown.

-LB
 
Yeah, I thought of that, I was just hoping to avoid it. Thanks everyone for all the help
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top