Link to home
Start Free TrialLog in
Avatar of E C
E CFlag for United States of America

asked on

Crystal Reports - need sum of a constant value

I am building a report that shows the details of every order we have processed in a month.

In addition to the cost of each item, there is a "processing fee" of $1.50.
This flat fee gets charged on every order, regardless of the contents of the order.

The order details come from a single flat file, but the processing fee is *not* part of the flat file.

In Crystal Reports, I created a formula that simply contains:
     procFee=1.5

If I drag that formula onto the Group Header, it shows up as $1.50

Now ... in the Report Footer, I want a grand total of processing fees.
When I place a Summary field into the report footer, this field (proceFee) does not appear in the list of fields to choose from.

I thought maybe Crystal Reports doesn't know this constant is formatted as a number, so I modified the formula to say "numberVar x := 5;"

Still no luck.

How can I calculate the sum of all processing fees when the processing fee is not part of the data?

I really don't want to add this field to the data file because I will have to do that each month when the new data file arrives.
SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of E C

ASKER

mlmcc,
Thank you, that worked.

I was trying to create a formula that simply returned a constant value (1.50), stick that formula field in the group header (as you mentioned, it's the Order Number) and then tell Crystal Reports to do give me the sum at the end of the report.

Your solution is to essentially forget about adding up $1.50 for every record. Instead, simply count the number of distinct order numbers, and multiply that by $1.50. Is that correct? (For my original question, this is perfectly acceptable and you've earned the points for that).

I was trying to figure out why Crystal doesn't let you add a Sum for a formula field, if the formula field only contains a constant value.

Maybe I have to do this on my own by creating a running total, like this:

1. Create a variable that persists throughout the report.

2. When the report is initialized, the value of this variable is set to $0.

3. As it iterates through each record, I could even apply some sort of test (for example: Processing Fees are $3.00 for Order Numbers that begin with a 'Z', otherwise the fee is $1.50"). The calculated value would be added to the variable (the running total).

4. By the end of the report, the total sum of processing fees would be whatever value is currently in that variable. I could simply place that variable into the Report Footer.

Is this possible?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of E C

ASKER

mlmcc,
thank you for taking time to help even after you answered the original question.

Ido,
thanks for the info on the 'WhileReadingRecords' command!