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.
LVL 11
ecarboneAsked:
Who is Participating?
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.

mlmccCommented:
Since you are doing it in a group header I can think of 2 ways.  

I assume the group is on the order number or some such field and that there is a 1.50 fee per order

Try

CountDistinct({OrderNumberField}) * 1.5

or better might be

CountDistinct({OrderNumberField}) * {@ProcessingFee Formula}

There is a way to make the fee available for the  summary but unless you have one order detail line per order the summary will add $1.50 er item or detail line.
But if that is what you want just change the CountDistinct to Count

mlmcc
0
ecarboneAuthor Commented:
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?
0
Ido MilletProfessor of MIS at Penn State Erie and Owner, Millet SoftwareCommented:
All you need to do is change the expression for your fee formula to:
WhileReadingRecords;
1.5;

This would make that formula a candidate for summing.
0
mlmccCommented:
If you base the fee on a formula involving database fields then it will be available

Even this is available even though it always returns 1.5

If {FIeld1} = {Field1} then
   1.5
ELSE
   2

SO if you used a formula like this it should be available.

If Left({YourField}),1) = 'Z' then
   3.0
Else
  1.5

If it isn't then change it to

WhileReadingRecords;
If Left({YourField}),1) = 'Z' then
   3.0
Else
  1.5


mlmcc
0

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
ecarboneAuthor Commented:
mlmcc,
thank you for taking time to help even after you answered the original question.

Ido,
thanks for the info on the 'WhileReadingRecords' command!
0
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.