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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Division in Crystal reports

Status
Not open for further replies.

irenavassilia

Programmer
Jun 19, 2007
101
Hi,

I have a Crystal Report v10 report where i have two running totals (i.e. #Total1, #Total2)

I need to divided these totals by each other within my @Sales formula located on the detail line:

#Total1/#Total2

When i try diving them i get an error saying:

A running total cannot refer to a print time formula

Can someone please help me out with this issue its the last puzzle to my report...


Thanks alot.
 
Sounds like you have a problem with one of the Running Totals. Remove your sales formula and just add the Rts to your detail line.

Do you get the same error?

Are the RTs based on a field value or a formula. If latter you may be doing a summary of using a variable in which case the RT will not work.

Alterantively you may have used a Run Time formul in the evaluation rulls for the RT. This will cause the RT to fail aswell.

YOu will need to replace the RT with another variable.

Ian

Ian
 
Hi Ian,

Thank you for replying.

In the detail line i have the #Total1 and #Total2 running totals displaying for each speficic field.

These running totals total up the formulas which are suppressed on the detail line.

i.e.

@VarianceCurrentMonthQuantity formula:
{@Quantity}-{@PriorQuantity}

#Total1 = sum(@VarianceCurrentMonthQuantity)
(reset on itemdesc field)

@PriorYearMonthQuantity formula:
if tonumber({UXDETAIL.FiscalYear}) = ({?Year}-1) and {UXDETAIL.FiscalPeriod} = {?month} then
{UXDETAIL.Quantity}

#Total2 = sum(@PriorYearMonthQuantity)
(reset on itemdesc field)

@Variance%Quantity formula:
#Total1/#Total2

I only get an error when i try to divide them or use them in another formula.

Hope this explains the logic a little better.

Thanks.





 
I assume you are not trying to do a summary on this formula
@Variance%Quantity As that would fail too.

Also to protect against divide by zero errors you should use

If #Total2 = 0 then 0 else
#Total1/#Total2

Sorry can not think of anything else which would cause the error you are seeing.

Ian


 
What is the content of your formula {@priorquantity}?

-LB
 
The content of that formula is:

if tonumber({UXDETAIL.FiscalYear}) = ({?Year}-1) and {UXDETAIL.FiscalPeriod} = {?month} then
{UXDETAIL.Quantity}


Thanks.
 
Where are you creating the formula that divides the two running totals?

-LB
 
I figured it out, i used Ian's advise on just assigning it to another variable and it worked.

Thanks.
 
never mind it doesnt work....

the formula is created in the detail line
 
I meant where are you going to create the formula? You should be in the field explorer->formula->new.

Now I'm wondering whether the issue is that the running total(s) might have null values until they reach records that meet your criteria. As an experiment, try changing your formula to:

if not isnull({#total1}) and
not isnull({#total2}) and
{#total2} <> 0 then
{#total1}/{#total2}

-LB
 
No the running totals having null values is not the issue.

The issue is when i need to create a grand total on this formula and when i try that it starts with the error.

Without trying to total this formula i get no errors.

But i need a grand total.

*Thinks*
 
Are you saying you only get this error when you try a second formula that sums the formula containing the running totals? If so, that's because you can't use
those kinds of summaries on running totals. Note that Ian mentioned this much earlier. To sum your formula, use a variable, as in:

whileprintingrecords;
numbervar sumx := sumx + {@Variance%Quantity};

You should place this formula in the section that contains the value in {@Variance%Quantity} that you want summarized. Then in the report footer, use:

whileprintingrecords;
numbervar sumx;

...to display the result.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top