# Crystal Reports - Formula - Need to do a custom summary

Hi. I have a report formatted like this: (group within a group)

CompanyA
...........InvoiceA
......................1..................23
......................5..................23
......................3..................23
......................4..................23
...........InvoiceB
......................6..................45
......................2..................45
......................1..................45
......................1..................45
................................ ||The spot||
CompanyB
...........InvoiceC
......................1..................55
......................9..................55
......................3..................55
......................1..................55
...........InvoiceD
......................6..................88
......................3..................88
......................3..................88
......................1..................88
................................ ||The spot||

I need to create a formula that sums the numbers (23 and44) and then (55 and 88).

As you can see these numbers are unique to the invoice, not to each line under an invoice.

The areas above that I have marked ||The Spot|| should read "68" and "143" respectively

I need a formula kind of like this:

Sum of InvoiceTotals for each Invoice where CompanyID = "companyA"

The "hitch" is that the details section of the report is Invoice Line Items -- so inevitably crystal grabs the value too many times for a normal summary (one time for each invoice line item)

Any ideas?

Thanks
###### Who is Participating?

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Try this using formulas a variables.

Add formulas in the specified sections
WhilePrintingRecords;
Global NumberVar CompanyTotal := 0;
''

WhilePrintingRecords;
Global NumberVar CompanyTotal;
CompanyTotal := 0;
''

WhilePrintingRecords;
Global NumberVar CompanyTotal;
CompanyTotal := CompanyTotal + {InvoiceTotalField};
''

In the Company Group footer
WhilePrintingRecords;
Global NumberVar CompanyTotal;
CompanyTotal

mlmcc
0

Experts Exchange Solution brought to you by