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!

How can I create a sum of sum?

Status
Not open for further replies.

denko

Programmer
May 17, 2001
70
US
How can I create a sum of sum?
I've got 2 groups Department(Gr2) and Company(Gr1). In GF2-Dept. I calculate total Profit/Losses per Dept. In GF1 I need to total Absolute value for Profit/Losses per Company.
For Example:

GF2

Dept1 3,000,000
Dept2 2,000,000
Dept3 -2,000,000

GF1
Company1
Gross Total 7,000,000

The problem is that Crystal does not let me create a sum of a sum, plus even though totals in GF1 could be negative i need to total them as positive.
Thanks
Den
 
CR always does it's sums from the detail level, which usually gives you the same result. You could write a formula that says:

If GroupField = 'x' then 0 - {Amount} else {Amount}. A grand total of this should be the same as a sum of the sums.

If you really need to do a sum of a summary field you have to use a running total field. Use the 3-Formula technique described in faq149-182. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Unfortunately it's not as easy as it seems. The kick is the way I need to calculate Absolute value for Totals of Gr1(Company)
Totals for Dept. group are calculated on real numbers(not absolute) but for Company total I need to take Dept totals and treat them as absolute.
Example:
Details
Dept1 1,000,000
Dept1 2,000,000
Dept2 2,000,000
Dept3 -5,000,000
Dept3 3,000,000

GF2

Dept1 3,000,000
Dept2 2,000,000
Dept3 -2,000,000

GF1
Company1
Gross Total 7,000,000
Now, if you notice that if I total details in Abs value it would give me 13,000,000 when I sum Abs.Totals from GF2 then it gives me 7,000,000.
I need to see 7 mil.
Thanks
 
Use a running total as mentioned in the FAQ and accumulate it on Group Footer2, taking tha absolute value of the subtotal before you increment the variable. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top