How to create a formula in VS2005 Crystal Reports

I am running VS 2005 Crystal Reports.

I have an Sql Query that selects part number records from inventory.  Each part number as 2 distinct inventory categorys, "0" and "9".  Therefore I am returning 2 records for every part number

I have created a Crystal Report that displays everything that I want except for the difference between the 2 inventory category values. My report looks like this::

123           widget              

                   0             $15.24
                   9             $15.00
                                  $00.24      <==== This is the field I am trying to calculate

456          next description

                   0             $20.00
                   9             $21.00

The part number is in the "GroupHeaderSection1" area of the report.  The inventory category and price are in the details section of the report.

Thanks for any help you can offer.  (in case you haven't guessed, this is my first Crystal report)...
SteveB2175Asked:
Who is Participating?
 
mlmccConnect With a Mentor Commented:
Try this

In the report header add a formula
Name - DeclVars
Formula
WhilePrintingRecords;
Global NumberVar PriceCat0;
Global NumberVar PriceCat9;
''
In the detail section
Name - SetCatPrice
Formula
WhilePrintingRecords;
Global NumberVar PriceCat0;
Global NumberVar PriceCat9;
If {CatField} = 0 then
    PriceCat0 := {PriceField};
else if {CatField} = 9 then
    PriceCat9 := {PriceField};
''

In the group footer
Name - DeclVars
Formula
WhilePrintingRecords;
Global NumberVar PriceCat0;
Global NumberVar PriceCat9;
PriceCat0 - PriceCat9

mlmcc



0
 
SteveB2175Author Commented:
Wow, it worked !!!

Thank you so very much, this would have taken me forever to figure out.

The only thing I changed was the last name in the group footer, I don't know if you intended for it to be the same name as the header formula or not.

Thanks again
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.