divid by zero exception Error

Horse06
Member Posts: 496
How expert, I have a dataset X in the RDLC report, which has expression as (sum A/sum
*100.
But when A is equal or less than zero, X will be showing ERROR since it is divided by zero exception. How to add the if condition to the dataset X to avoid the error? Thank you!

But when A is equal or less than zero, X will be showing ERROR since it is divided by zero exception. How to add the if condition to the dataset X to avoid the error? Thank you!
0
Comments
-
If you wanna perform your control directly in TextBox you can use an expression like this:
=IIf(Sum(Fields!B.Value)=0,0,Sum(Fields!A.Value)/Sum(Fields!B.Value)*100)
* Daniele Rebussi * | * Rebu NAV Diary *0 -
Thank you expert! I tried it as below, but it still shows error. Thank you!
=IIF((Sum(Fields!TL1.Value)-Sum(Fields!TL2.Value))=0,0,sum(fields!Mship1.Value)-sum(Fields!Mship2.Value))/(Sum(Fields!TL1.Value)-Sum(Fields!TL2.Value))*100)0 -
Hi Expert,
I tried again using the following expression for the textbox control
=IIf(Sum(Fields!TS.Value)=0,0,Sum(Fields!MS.Value)/Sum(Fields!TS.Value)*100)
It is the same result. For those TS that are not zero, the numbers are correct, but if the TS is zero, it stil shows error.
Please advise, expert! Thank you!0 -
Just checked...didn't know IIf statement was so tricky: preparing the argument list the compiler calls every function in every expression so it's not possible to rely on "else" part not being executed. To avoid this it's possible to use a nested IIf, transforming previous expression in:
=IIf(Sum(Fields!TS.Value)=0,0,Sum(Fields!MS.Value)/IIf(Sum(Fields!TS.Value)=0,1,Sum(Fields!TS.Value))*100)
Try this and let me know* Daniele Rebussi * | * Rebu NAV Diary *0 -
Dear,
Make Sure checking both value in divide calculation, try this and hope it works
=IIF(SUM(Fields!TS.Value) = 0,0,IIF(SUM(Fields!MS.Value)=0,0,(SUM(Fields!MS.Value)/SUM(Fields!TS.Value))*100)))0 -
Thank you, experts!
I tested both. geordie's code is working now. Thank you very much!
william_marcelinus's code seems like the error will not go away.
Thank you for both experts!0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions