#Error when dividing values in SSRS

When building a report in SSRS using a SQL Query, I have come across the #Error message when trying to divide two values in the report, for example;

=SUM(Fields!Project_Work.Value) / (SUM(Fields!Project_Work.Value) + SUM(Fields!Admin.Value))

To fix this, I applied the following code to the report;

Public Function Divide(ByVal first As Double, ByVal second As Double) As Double
 If second = 0 Then
  Return 0
 Else
  Return first / second
 End If
End Function

Then against the cell, used the code (Note: Instead of using / we use , to get things working);

code.Division(Fields!Project_Work.Value, Fields!Admin.Value)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s