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

Sum of a Sum 1

Status
Not open for further replies.

NiceArms

Programmer
May 21, 2009
105
GB
Having read several posts on several forums I am becoming increasingly worried that there is no resolve for my problem.

I am trying to sum a sum in Crystal 9.

*Firstly I tried to sum a running total which failed.
*Secondly I tried to sum a sum which also failed.
*Thirdly I tried to put a running total in the evaluation section of a running total with a variable reset at in the header i.e.:

NumberVar lessthan1;
WhilePrintingRecords;
if Sum ({FIELD}, {FIELD}) > 0 then
if Sum ({FIELD}, {FIELD}) < ({FIELD} / 100) then
lessthan1 := lessthan1 + 1;

lessthan1 = 1

Which also failed!

Does anyone know how to sum a sum in crystal reports?

/Nice
 
Totals have to be based on individual detail lines. If you want to see totals for groups and also for the same report, say, then these would have to be done separately.

The positive side is that it's very easy to create all sorts of totals without needing to code them. The use of Crystal's automated totals is outlined at FAQ767-6524.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 10 & 11.5 with Windows XP [yinyang]
 
Yes, you can sum sums, but I can't tell what you're doing. Please show some sample data at the detail level with the group sums shown, along with the expected sum of sums.

Also, it appears you are trying to sum only certain sums that meet criteria. Please identify the criteria in words and when you show formulas, show the actual field names instead of just "field".

-LB
 
Wonderful news.

apologies for the lack of clarity in my first post.

You are right I am trying sum/count based on a specific selection criteria.

example data:

Account - Balance - Paid - Month Opened
12345 - £1000 - £0.01 - 01/02/2009
12345 - £1000 - £0.02 - 01/02/2009
54321 - £200 - £50.00 - 01/02/2009
98765 - £100 - 100.00 - 01/02/2009

I have 1 groups:
Group 1 is on the Month Opened

I want to count the number of accounts that have made a payment < 2.5% of the balance and show this in the group footer. The issue I am struggling with is (as you can see in the example data) there is a single account with 2 payments which need to be summed to confirm if these 2 payments are < 2.5% of the balance.

What i tried was to place a sum of the payments into a grouping of the account, evaluate as to if the value = the criteria and then summing these results into the month opened footer.

/Nice


 
Insert a group on account and then create a formula like this:

whileprintingrecords;
numbervar cnt;
if sum({table.paid},{table.acct}) % maximum({table.balance},{table.acct}) < 2.5 then
cnt := cnt + 1;

Place the above formula in the account group section and suppress it. Create a reset formula and place it in the month group header and suppress it:

whileprintingrecords;
numbervar cnt;
if not inrepeatedgroupheader then
cnt := 0;

In the month group footer, use this formula:
whileprintingrecords;
numbervar cnt;

-LB
 
LB, thank you.

I did try something very close to your suggestion but it fell down when using 2 groups.

I have resolved the issue as follows.

global lt25 as number
global Account as string

if Account <> {account} then 'ensure that the last account is not the same
if {#RT paid} > 0 then 'ensure a payment has been made and not reversed off
if ({#RT paid} < (Balance * 0.025)) then 'ensure that the total paid to a single is account is lt 25% fo the balance
lt25 = lt25 + 1
end if
Account = {Account} 'update the account variable for the next run
end if
end if

formula = lt25

I placed the above into the detail section and used the following to display the total in the group footer.

whileprintingrecords
global lt25 as number
formula = lt25

Note: using this process I was able to reduce the groups to just the 1.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top