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!

Manual Running Total Sum

Status
Not open for further replies.

st7979

Programmer
Oct 19, 2009
15
US
Hi,

I am having trouble doing a manual running total sum on a formula and this Formula A cannot be sum by the built in function from Crystal 10.

Goal: I need to have a grand total on Formula A.

//Placed on the group footer
Formula 1
Whileprintingrecords;
Shared numbervar totalsum;

totalsum := totalsum + Formula A;
//The totalsum is correct at the last page on the group footer, however, when i create another formula for total sum and put it on the report footer, it is adding Formula A twice.

//Place on the report footer
Formula 2
Whileprintingrecords
Shared numbervar totalsum;
totalsum;

For example,

FormulaA on group 1 footer
1 Totalsum = 1
2 3
3 6
4 10
5 15

However the totalsum I placed on report footer is 20. How can I fix this?

Thanks
 
I think you should make sure you don't have a copy of your accumulation formula (formula1) in the report footer.

-LB
 
Hi Ibass,

I don't have any accumulation formula in the report footer. I tried to change my formula to sum other columns, and whenever the last column has a nonzero value, it always sum extra of that amount. As a workaround now, I created a group footer 1b and put the total there. I will suppress this 1b until the last record so it will look like a report footer. Of course, the column that i wanted to sum are from alot of different subreports embedded in the group header. I'm not sure if that's the reason of this cause. If you can think of any other ways, please let me know.

Thanks!!
 
Is your sum coming from a subreport?

-LB
 
Sorry, I see that it is. If you are trying to sum a shared variable from a subreport, set it up like this, and place it in a section after the one containing the sub--if the sub is in GH_b, place this formula in a GH_c section:

Whileprintingrecords;
Shared numbervar totalsum;
numbervar x := x + totalsum;

Then reference the following in the report footer:

Whileprintingrecords;
numbervar x;

You probably need a reset formula for your shared variable, also. This formula should be placed in a section immediately above the one containing the sub, so if the sub is in GH_b, the reset should be in GH_a (or you could put it in the corresponding GF in a section AFTER the one containing the reference to the shared variable:

whileprintingrecords;
shared numbervar totalsum := 0;

-LB
 
Hi,

The column is coming from the sum of the subreports and main and I wanted to sum that sum amount. I'll try to use your suggestions and see if it works. Thanks!

ie
Number from sub & main Result I want to get
1 1
2 3
3 6
4 10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top