How to make a summary function from multiple fields?

We have a crystal report template we use for creating invoices.  We need to summarise the taxes, the problem is, the taxes are compound taxes, and not always made up of the same components.

Each item on the invoice can have up to three taxes defined. Local, State, plus withholding taxes, of which there are over 15 kinds.  In the database we have six fields, three that define which tax has been used, and what the tax amount is.  For example:

Desc                                           Price     TaxCode1  Tax Amount1  TaxCode2  Tax Amount2  TaxCode3  Tax Amount3
Widget 1                                   100.00       VAT               10.00               Empty                        0     Empty                 0
Widget 2                                    100.00      VAT                10.00             PPN                11.00          Empty                 0
Widget 3                                    100.00      PPN                10                 PPH23              -2.30         PPH25               -10.00

What I need in the footer is

VAT           20.00
PPN          21.00
PPH23     -2.30
PPH25     -10.00

Can anyone tell me how to make a Crystal Reports Function to calculate these summaries.

The complication is the tax names, and taxes used, varies from invoice to invoice, and from installation to installation.  So we need to summarize them based on the names in the actual database.

Many thanks for you help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

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.

Try this idea that uses formulas with arrays to track the tax names and amounts.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
If you are printing multiple invoices on a report use this one.  Same report but a group on invoice number is added and the totals are reset in the group header

townsmaAuthor Commented:
Great answer, appears to work perfectly.

Many thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Crystal Reports

From novice to tech pro — start learning today.