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

Summary on an aggregate function

Status
Not open for further replies.

skurkal

IS-IT--Management
Apr 6, 2005
37
US
Hi,

I am using Crystal XI, on a SQL database.
Example of the problem I am having is as follows:

Company A
Col1
-----
10
20
30
---
SubTotal: 60

Company B
Col1
-----
15
25
10
---
SubTotal: 50

Col1 is calculated using a formula that uses the 'sum' function. So in order to calculate the subtotal of this column, for each company I created the following formula :

WhilePrintingrecords;
NumberVar SubTot;
SubTot := SubTot + @Col1 //function col1

I placed this formula in the Company GroupFooter section, but with incorrect results.

What do I need to do in order for to calculate the subtotal correctly, for each company.

Thanks for you help,
Sumi.

 
Col1 is calculated using a formula that uses the 'sum' function.", so post it.

Given your description, you should be able to just right click the col1 in the details and select insert-Summary-sum and it will create a sum in the report footer.

Or use:

sum({tabel.col1})

If those fail, then we need more info, sucg as the orginal formula and what the incorrect results are with your formula, as it should work, depending on what's in {@col1}.

-k
 
I think SV is right, that sum({table.col1},{table.company}) might be sufficient. But if you need to use your formula, it should be placed in the inner group section where you are displaying {@col1}. Then create a separate display formula to place in the company group footer:

WhilePrintingrecords;
NumberVar SubTot;

And you will need a reset in the company group header:

WhilePrintingrecords;
NumberVar SubTot := 0;

-LB

 
Thanks, Lbass. Your solution worked perfectly.

Since my formula for calulating Col1 had a aggregate function in it, I could not use the sum function to add up the values, as crystal does not allow summing a formula that has a total in it.

It did not make much sense to post the entire formula on this thread because, one that was not the problem and second the field contents of the formula would not make much sense to anyone reading it.

Your solution was exactly what I was looking for, and it worked. Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top