[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Division by Zero

Posted on 2008-06-13
6
Medium Priority
?
349 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
Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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. …
Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 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