SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 code.Utility.SafeDivide
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

410 Posts

Posted - 01/27/2013 :  06:27:34  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3724 Posts

Posted - 01/27/2013 :  17:13:58  Show Profile  Reply with Quote
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

India
52325 Posts

Posted - 01/28/2013 :  00:09:16  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000