?
Solved

Division by Zero

Posted on 2008-06-13
6
Medium Priority
?
348 Views
Last Modified: 2012-08-13
Hi there,

I am getting a division by zero error again. I had the similar issue in March and I posted a question regarding it (please see post # 23209772). I applied the solution recommended and the report has been working fine until this month where I am getting the same error again. The formula that I am using is below:

If (Sum ({@Oct 07}, {@Item / Variant})) +  (Sum ({@Nov 07}, {@Item / Variant})) + (Sum ({@Dec 07}, {@Item / Variant}))  + (Sum ({@Jan 08}, {@Item / Variant})) + (Sum ({@Feb 08}, {@Item / Variant})) + (Sum ({@Mar 08}, {@Item / Variant})) + (Sum ({@Apr 08}, {@Item / Variant})) + (Sum ({@May 08}, {@Item / Variant}))= 0 and (Sum ({@Oct Plan 07}, {@Item / Variant})) + (Sum ({@Nov Plan 07}, {@Item / Variant})) + (Sum ({@Dec Plan 07}, {@Item / Variant})) + (Sum ({@Jan Plan 08}, {@Item / Variant})) + (Sum ({@Feb Plan 08}, {@Item / Variant})) + (Sum ({@Mar Plan 08}, {@Item / Variant})) + (Sum ({@Apr Plan 08}, {@Item / Variant})) + (Sum ({@May Plan 08}, {@Item / Variant}))> 0
then "FES"
else if (Sum ({@Oct 07}, {@Item / Variant})) + (Sum ({@Nov 07}, {@Item / Variant})) + (Sum ({@Dec 07}, {@Item / Variant})) + (Sum ({@Jan 08}, {@Item / Variant})) + (Sum ({@Feb 08}, {@Item / Variant})) + (Sum ({@Mar 08}, {@Item / Variant})) + (Sum ({@Apr 08}, {@Item / Variant}))+ (Sum ({@May 08}, {@Item / Variant})) >0 and (Sum ({@Oct Plan 07}, {@Item / Variant})) + (Sum ({@Nov Plan 07}, {@Item / Variant})) + (Sum ({@Dec Plan 07}, {@Item / Variant})) + (Sum ({@Jan Plan 08}, {@Item / Variant})) + (Sum ({@Feb Plan 08}, {@Item / Variant}))+ (Sum ({@Mar Plan 08}, {@Item / Variant})) + (Sum ({@Apr Plan 08}, {@Item / Variant}))+(Sum ({@May Plan 08}, {@Item / Variant})) = 0
then "SEF"
else if (Sum ({@Oct 07}, {@Item / Variant})) + (Sum ({@Nov 07}, {@Item / Variant})) + (Sum ({@Dec 07}, {@Item / Variant})) + (Sum ({@Jan 08}, {@Item / Variant}))+ (Sum ({@Feb 08}, {@Item / Variant})) + (Sum ({@Mar 08}, {@Item / Variant})) + (Sum ({@Apr 08}, {@Item / Variant})) + (Sum ({@May 08}, {@Item / Variant})) = 0 and (Sum ({@Oct Plan 07}, {@Item / Variant})) + (Sum ({@Nov Plan 07}, {@Item / Variant})) + (Sum ({@Dec Plan 07}, {@Item / Variant})) + (Sum ({@Jan Plan 08}, {@Item / Variant})) + (Sum ({@Feb Plan 08}, {@Item / Variant})) + (Sum ({@Mar Plan 08}, {@Item / Variant}))+ (Sum ({@Apr Plan 08}, {@Item / Variant}))+(Sum ({@May Plan 08}, {@Item / Variant}))= 0 then '1'
else
CStr (((Sum ({@Oct 07}, {@Item / Variant})) + (Sum ({@Nov 07}, {@Item / Variant})) +(Sum ({@Dec 07}, {@Item / Variant})) + (Sum ({@Jan 08}, {@Item / Variant}))+ (Sum ({@Feb 08}, {@Item / Variant}))+ (Sum ({@Mar 08}, {@Item / Variant}))+ (Sum ({@Apr 08}, {@Item / Variant}))+ (Sum ({@May 08}, {@Item / Variant})) )/((Sum ({@Oct Plan 07}, {@Item / Variant})) + (Sum ({@Nov Plan 07}, {@Item / Variant})) + (Sum ({@Dec Plan 07}, {@Item / Variant}))+ (Sum ({@Jan Plan 08}, {@Item / Variant}))+ (Sum ({@Feb Plan 08}, {@Item / Variant}))+ (Sum ({@Mar Plan 08}, {@Item / Variant}))+ (Sum ({@Apr Plan 08}, {@Item / Variant}))+(Sum ({@May Plan 08}, {@Item / Variant})))  * 100)


Thanks




0
Comment
Question by:sgaurav7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 21782121
What is @MONTH XX, and @ITEM/VARIANT code?

mlmcc
0
 

Author Comment

by:sgaurav7
ID: 21782251
@MONTH XX is the formula to get the invoiced sales for the current fiscal year

For example, the formula for April 2008 ({Apr 08}) comes from:

if {@Year Selection = '2008'
and Month ({BU_SFA_DETAIL2.invoice_dt}) = '4'
then {BU_SFA_DETAIL2.quantity}

@Item/Variant is just the concatenation of the Item_no and variant_no (Product Code and the Size)
{BU_SFA_DETAIL2.item_no} + '/' + {BU_SFA_DETAIL2.variant_no}
0
 
LVL 42

Expert Comment

by:frodoman
ID: 21782845
It looks to me like the part of your last 'else' statement below the division sign must evaluate to zero.  In other words for some value of {@Item/Variant}, the sum of all of the months is equal to zero.

If you need to be excruciatingly accurate you'll need to check this to make sure it's <> 0 before you do the calculation.  If you can tolerate a very small error then you can probably fix easier by adding 0.0000001 to the value below the division sign.  Eg:

....}))+(Sum ({@May Plan 08}, {@Item / Variant})))  * 100)

becomes

....}))+(Sum ({@May Plan 08}, {@Item / Variant})))  * 100 + 0.0000001)

This insures that the value will never be zero.  It does alter the results very slightly - if you're dealing with common scenarios it's below what you'll be rounding anyway but if you're dealing with precision that tight than you'll have to use an "if" statement.

frodoman
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 42

Accepted Solution

by:
frodoman earned 2000 total points
ID: 21782858
Correction - I think I miscounted the parenthesis.  The modified value would be:

....}))+(Sum ({@May Plan 08}, {@Item / Variant})) + 0.0000001 )  * 100)


frodoman
0
 
LVL 101

Expert Comment

by:mlmcc
ID: 21783101
Could there possibly be no data for May08?

mlmcc

0
 

Author Closing Comment

by:sgaurav7
ID: 31467034
You are genius....this worked just fine. thanks!
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question