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

Need group sum of lower group formula

Status
Not open for further replies.

Homestead

Programmer
Sep 17, 2004
1
US
Crystal Report 9.
Use formulas in group level 2 to perform math on detail amount fields. Need to sum those fields in group level 1.

For example:
Detail line lists Policy number and amount.
Group level 2 totals by Owner tax ID.
The formulas in group level 2 are for:
Formula 1: Lesser of total amount or $250,000
Formula 2: If total amount > 250,00 then the difference between those two amounts else 0
Formula 3: Formula 1 times .075

I need to sum those formulas for the Group level 1 which reflects totals on a Company basis.

The "sum" key does not list the group formula fields.

Formulas cannot reference themselves.

A new formula that adds the value of the group level 2 formula gets reset with each group level 2 and ends up only containing the total from the last group level 2 formula.

I am open for suggestions.

Thanks,
 
Those aren't the formulas you used, they are descriptions of them, try posting what you use.

Depending upon how you did this, you may have to create additional formulas for the outer grouping.

Here's the standard 3 formula approach, used for both group:

GL1 Header:
whilprintingrecords;
numbervar G2Sum:=0;

In the GL 2 header place:
whileprintingrecords;
Numberver G2Tot1:= 0
Numberver G2Tot2:= 0

Details:
whileprintingrecords;
Numberver G1Tot:= G1Tot+{table.field1};
Numberver G2Tot:= G2Tot+{table.field1};

G2Footer:
@G2Display
whileprintingrecords;
Numberver G1Tot;
Numberver G2Tot;
If G2Tot+G2Tot => 250000 then
minimum([G2Tot,G2Tot)
else
G21Tot*.075

Now a quick cheat is to reference the G2Footer formula in the G2 Footer to sum it for the outer group:

whilprintingrecords;
numbervar G2Sum:=G2Sum+@G2Display

Then in the GF1 use:

whilprintingrecords;
numbervar G2Sum

Should get you close, it's hard to say without knowing technical information.


A clear way to convey tech info and allow for advanced architecture:

Crystal version
Database/connectivity used
Example data
Expected output (show groupings, and the results)

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top