Solved

Division by Zero

Posted on 2008-06-13
6
339 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
  • 2
  • 2
  • 2
6 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
What is @MONTH XX, and @ITEM/VARIANT code?

mlmcc
0
 

Author Comment

by:sgaurav7
Comment Utility
@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
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 42

Accepted Solution

by:
frodoman earned 500 total points
Comment Utility
Correction - I think I miscounted the parenthesis.  The modified value would be:

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


frodoman
0
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
Could there possibly be no data for May08?

mlmcc

0
 

Author Closing Comment

by:sgaurav7
Comment Utility
You are genius....this worked just fine. thanks!
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now