-
May 18th, 2015, 10:35 AM
#1
Crystal Report Division by zero error
I am trying to replace an embedded summary field with a formula - so I can sort on the field. I am taking the variance amount and dividing it by the budget amount to come up with a variance percent.
Here are several formulas I have tried without success. I either get a 'division by zero' error or invalid data.
if isNull(@Budget) Then 0
Else (@Variance) / (@Budget)
*******
evaluateafter(@Variance);
if(@budget)<> 0 Then
(@variance) / (budget)
else 0
*******
evaluateafter(budget);
if (variance) <> 0 then
if(budget) <>0
then (variance) / (budget)
else 0
thanks in advance for any help provided.
-
May 20th, 2015, 12:17 PM
#2
Re: Crystal Report Division by zero error
Hello,
I suggest your testing on the divisors does not cover all possible values. In your first example you test for a null divisor, but not a zero value divisor. In the next 2 examples you test for zero, but not null.
If IsNull(@Budget) Then 0
Else If (@Budget) = 0 Then 0
Else (@Variance / @Budget)
-
May 20th, 2015, 01:07 PM
#3
Re: Crystal Report Division by zero error
Hi Ned,
That makes sense; however, when I changed my formula to your suggested one, I now get large numbers for the variance percent.
Here's an example:
Budget Variance Variance % (should be) Formula (this is what I get now)
278.7 (15.5) (5.6) 2,941
92.1 (14.3) (15.5) 2,666
-
May 21st, 2015, 11:06 AM
#4
Re: Crystal Report Division by zero error
Hello,
The values you are seeing are not related to the testing for a null and/or zero divisor. That test simply allows the division to take place. You will need to examine your data, and your @Variance and @Budget formulas to determine why you are not getting the desired results.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|