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

Subtracting 2 Running Totals

Status
Not open for further replies.
Dec 13, 2004
63
US
I am using CR10 with an Oracle database.

Here's the situation:

I have 2 effective dates in my database which are
10/1/2004 and 10/1/2005.

I created a group in my report based on the effective dates, which is GROUP 1.

I created a running total in GROUP FOOTER 1 to count the number of females for each effective date (10/1/2004 and 10/1/2005). The running total was placed in Group footer 1.

Now, I am trying to subtract the running total that is displayed in the 10/1/2004 group from the runnning total that is display in the 10/1/2005 group. Remember there is only one group on the report, which is Group1.

For example, the report looks something like this:

Group1: 10/1/2004 Females: 6000
Group1: 10/1/2005 Females: 5000

I would like to show the 1000 difference.
How can I do this? Please help!
 
I really need help! As I am pondering different solutions to my problem, I though of another question.

Is there a way to subtract a current running total from a previous running total?

Please help!
 
The running total for a group is cleared when the next group is begun.

What you could do is have two running totals, each using a formula to evaluate for just one group, with a value you hard-code. Then you can find the difference in the report footer.

Or do just one formula-evaluating total and use it in the group footer of the second group, putting it in a section that is otherwise suppressed.

[yinyang] Madawc Williams (East Anglia, UK). Using Windows XP & Crystal 10 [yinyang]
 
Create a new formula and place this in the same section as your running total

Code:
//@CalcDifference
Shared NumberVar Group1;
Shared NumberVar Difference;

If Group1 = 0 Then
     Group1 := #RTotal
Else
     Difference := Group1 - #RTotal;

Then create a 2nd formula and place in the report footer section

Code:
//@DisplayDifference
Shared NumberVar Difference;

HTH


Gary Parker
MIS Data Analyst
Manchester, England
 
Thanks Gary and Madawc! I really appreciate your help. I used Gary's formulas and it works.

Thanks Again!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top