Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

All the results on my formula are zero 1

Status
Not open for further replies.

SebaPerez

Programmer
Feb 11, 2004
9
FR
Hi, I am new using this software and I need urgent help.

This is the situation.

I have a report with the following field

Program Expenditure Allotment Expenditure Rate
(A) (D) (A/D) * 100

Program 01 1,946,194.65 0.00 0.0
Program 02 709,451.25 0.00 0.0
Program 03 604,969.20 1,892,450.00 0.0
Program 04 8,400,932.32 0.00 0.0

The totals of Expenditure and Allotments are formulas (@Expenditure and @Allotment).

The last column (Expenditure Rate) is the one I want to calculate. After controlling the "Division by zero" problem all the results in that last columns are Zero.
This is what I am doing:

IF {@Allotment} <> 0 THEN
({@Expenditure}/{@Allotment})*100
ELSE
0

What am I doing wrong ? Thanks you in advance for any help. Maybe it is a very stupid question but as i told before I am a beginner.

Seba
 
The problem is probably evaulation time. Since you are using two formulas' results in your last formula, you should add &quot;whileprintingrecords&quot; to your rate formula. Your new formula would look like this:

whileprintingrecords;
IF {@Allotment} <> 0 THEN
({@Expenditure}/{@Allotment})*100
ELSE
0


Mike
 
Or the problem likely lies in the @Expenditure formula. If Mike's suggestion doesn't work, post the @Expenditure and @Allotment formulas.

-dave
 
Thanks for responding so quickly...

I have already tried with mbarron advice and it doesn't work. How can I explain better the situation.

The @Expenditure and @Allotment formulas are calculated as follows. I have a field called POSTED_BASE_AMT where I have all the amount and an another field called LEDGER with a string which I make a filter for the SUM

@Expenditure -->
if {wpo_oc_1.LEDGER} = &quot;ACTUALS&quot; then wpo_oc_1.POSTED_BASE_AMT}

The same for the Allotment
@Allotment -->
if {wpo_oc_1.LEDGER} = &quot;ALLTMNT&quot; then {wpo_oc_1.POSTED_BASE_AMT}

Then I used the &quot;Insert Summary&quot; option to generate my subtotals for each Program which I have grouped.

After having all the information I make the Expenditure Rate formula to calculate it from the other formulas. I hope this clarifies things.

Thanks

Seba

 
This looks like it should work as is. Did you by any chance use any special formatting on the value in the expenditure rate column?

-LB
 
So the rate is calculated on the summaries of the formula, not the formulas itself.

The formula you are using is using the values for the last formula in your details section. Or the first value if your summaries are in the header.

You need to use the summary fields, not the formula fields in your formula:

whileprintingrecords;
IF sum({@Allotment},{your.group}) <> 0 THEN
(sum({@Expenditure},{your.group})/sum({@Allotment},{your.group}))*100
ELSE
0




Mike
 
To lbass: No I havn't used any special formatting.

To Mike: I have tried what you told me but now instead of having only 0.0 values I have got directly no values. Obviously that last thing changed something but I wouldn't have a clue what to do. What can be possibly happening ?

Sebastian
 
If you are using a version of Crystal below 9 your could send the file to me, and I'll take a look at it. Make sure you have the File / Save Data with Report checked.

mail it to:
mbarron at arkwright dot com

Mike
 
Mike--good catch. I wrongly assumed that the summaries were being used in the formula.

-LB
 
I've sent your file back.

You needed to put the formula in the group header (with the summaries) not in the details section.

Mike
 
Mike

Thank you very much. It worked perfectly.

Sebastian
 
So just for a lesson-learned issue:

What was the problem with my report on the initial steps before you helped me?. What was the difference between having it on the detail section or in the group one?.

In the same example now, if I want to apply the same formula to the TOTALS what should I do?. Because if I copy that formula into the Report Footer, where I have the totals of the other 2 formulas, it won't work. If you want you can send me the file again with this issue.

Thanks again.

Sebastian
 
With the formula using the summaries in the detail section, it was calculating the groups rate for each detail line.


The basic syntax for a summary operation(sum, average, count, etc.) operation is:
summary(field to be summarized, the group you are summarizing for)

Using part of your formula:
Sum ({@Allotment}, {wpo_oc_1.WPO_PRGM_L3_NDE})
is the Sum of the {@Allotment} formula field, for the grouping based on the {wpo_oc_1.WPO_PRGM_L3_NDE} field.

To summarize the field for the entire report the format is simply summary(field). The formula you would need to create to summarize the ER for the whole report would be:

IF Sum ({@Allotment}) <> 0 THEN
(Sum ({@Expenditure}) /
Sum ({@Allotment}) )
*100
ELSE
0

Send me another email if you want your report back. I deleted your first email.



Mike
 
Okay... I could manage to do that so don't worry. Thanks a lot for the info.

Sebastian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top