Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 code.Utility.SafeDivide

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2013-01-27 : 06:27:34
What is this mean in SSRS expression:

=code.Utility.SafeDivide( Sum(Fields!A.Value), Sum(Fields!B.Value) )

What if I take it out code.Utility.SafeDivide, how can I apply the same expression as above?

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-01-27 : 17:13:58
Peace, googling for it, it seems like it is a .Net library that protects against division by zero: http://msdn.microsoft.com/en-us/library/dd578496.aspx Assuming it is the same library that you are using, if division by zero is not a consideration, you can use
=Sum(Fields!A.Value)/ Sum(Fields!B.Value)
If the denominator happens to be zero, I think the report will show Infinity. If you want to avoid that, you can use an expression depending on what you want to display in that case.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-01-28 : 00:09:16
you can put a logic like below to avoid it
=IIF(Sum(Fields!B.Value)=0,0,IIF(Sum(Fields!B.Value)=0,0,Sum(Fields!A.Value)/ Sum(Fields!B.Value)))

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -