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

Cyrstal Reports 8.5 Newbie - Need Help with SUM Function

Status
Not open for further replies.

cbayles

IS-IT--Management
Nov 18, 2003
11
US
I'm writing a summary invoice report that has the following columns:

INV# Subtotal Freight Tax Invoice Total

Here are the formulas that I created:
Subtotal: Sum({@Extended_Price},{invoice_view.invoice_no})

Since the freight and tax amounts on the invoice are listed on each invoice line item, I had to average them:

Freight: Average({invoice_view.freight},{invoice_view.invoice_no})

Tax: Average({invoice_view.tax},{invoice_view.invoice_no})

How can I sum these three formula fields to come up with an invoice total? I've tried the normal sum function without any luck. Can this be done?

Any help would be greatly appreciated.
 
Did you try:
Sum({@Extended_Price},{invoice_view.invoice_no}) +
Average({invoice_view.freight},{invoice_view.invoice_no}) +
Average({invoice_view.tax},{invoice_view.invoice_no})

MrBill
 
Thanks! That worked great! Now how do I get Crystal to give me a grand total of the invoice total field? Crystal doesn't give me the @Invoice Total field to calculate a grand total by.
 
So your report is for multiple invoices then? And is it grouped by invoice as well?

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
askdon@srhconsulting.com
 
Since you are trying to get totals at more than one level, you will run into problems with your "average" formulas. I would take a different approach. What you really need is a new formula at the detail level that adds the invoice_view.freight and Invoice_view.tax to the {@extended_price} on only the first record. Then use the sum function at any level you want.

formula: @LineTotal

// first line of invoice.
If {invoice_view.invoice_no} <> Previous({invoice_view.invoice_no}) then
{@Extended_Price} + {invoice_view.freight} + {invoice_view.tax} else

// remaining lines of invoice.
{@Extended_Price}

Place this formula in your detail section. You can suppress it if you need to. You should be able to sum this formula at any level.

MrBill
 
Yes, it's a listing of invoices groupeb by invoice #.
 
This will require variables and the 3 formula approach:

In the group header:
WhilePrintingRecords;
If Not InRepeaedGroupHeader then Numbervar InvGT:=0

In the group footer:
WhilePrintingRecords;
Numbervar InvGT:=InvGT+{@Invoice Total}

In the report footer:
WhilePrintingRecords;
Numbervar InvGT

Software Sales, Training, Implementation and Support for Exact Macola, eSynergy, and Crystal Reports
askdon@srhconsulting.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top