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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Analysis Server and Reporting Services (2008)
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Constraint Violating Yak Guru

420 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

3873 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: 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

Very Important crosS Applying yaK Herder

52326 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

Go to Top of Page
  Previous Topic Topic Next 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.02 seconds. Powered By: Snitz Forums 2000