Question:

How do you do basic math formulas in Crystal Reports? Argh!?

by  |  earlier

0 LIKES UnLike

I have a basic Crystal Reports report that has two columns of numbers in it. One for Gross Sales, one for Tax Amount. I want to have a third column that shows Gross Sales minus Tax Amount. I know I need a formula for this, but can't figure out how to make even this simple formula work. I've spent hours on this. Help!

 Tags:

   Report

1 ANSWERS


  1. There are a couple of solutions.  In my answer I will assume that your DB table is named YOURTABLE and your DB columns are named GROSSSALES and TAXAMOUNT.

    The best solution is to create a formula, e.g. Net Sales, and to define it as:

    {YOURTABLE.GROSSSALES} - {YOURTABLE.TAXAMOUNT}

    Then display this formula in the Details section of your report.  If you have any group sections or page/report sections with subtotals or totals, you can simply insert a sum() of the Net Sales formula within the appropriate Group/Page/Report header/footer areas.

    Another solution (although in my opinion not as good) will depend on how your report is designed.  Are the Gross Sales and Tax Amount columns generated as a sum() within a group section or are they being displayed in the detail section?

    In either case you still need to create a formula to subtract the tax amount from the gross sales.

    If the two data columns are displayed in the detail section, then the formula (e.g. Net Sales - Detail) would be:

    {YOURTABLE.GROSSSALES} - {YOURTABLE.TAXAMOUNT}

    If the two data columns are displayed as a sum() in a group section (I'll assume the section is grouped on the COMPANY field), then the formula (e.g. Net Sales - Company) would be:

    sum({YOURTABLE.GROSSSALES}, {YOURTABLE.COMPANY}) - sum({YOURTABLE.TAXAMOUNT}, {YOURTABLE.COMPANY})

    Enjoy!

    Jeff

    UPDATE 8/26/08:

    Mike,

    Have you tried either of my solutions?  Add a comment to your question if you need more clarification from me.

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.
Unanswered Questions