Solved

Division by Zero

Posted on 2008-06-13
6
346 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
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 
LVL 42

Accepted Solution

by:
frodoman earned 500 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

687 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