all groups > sql server reporting services > december 2004 >
You're in the

sql server reporting services

group:

How to replace #Error to 0 (Zero)


How to replace #Error to 0 (Zero) Sam
12/27/2004 3:37:02 PM
sql server reporting services: I have some report fields with complex expressions. The expression includes
functions like abs(), sum() as well arithmetic operations.
Example:
=Code.GetSumResult(
iif(Fields!Measures_A.Value.ToString().IndexOf("Percentage") > 0,
Fields!Measures_Xyz.Value, iif(Fields!Measures_A.Value.ToString().ToUpper() =
"ABC" or Fields!Measures_A.ToString().ToUpper() =
"EFG",ABS(Convert.ToInt32(Fields!Measures_B.Value)),
sum(Fields!Measures_C.Value))/1000))

Now Code.GetSumResult( ) function converts any of the value "NaN" or
"Infinity" or "-Infinity" value to 0 (Zero). I am unable to convert "#Error"
to zero. How can I detect the input value is "#Error". I tried InputVal = ""
or IsDBNull(InputVal) or IsError(InputVal) or InputVal Is Nothing etc..but
unable to detect "#Error" value.

Please let me know anyone knows how to resolve it.
Thanks,
Re: How to replace #Error to 0 (Zero) Bruce L-C [MVP]
12/28/2004 7:43:03 AM
The reason you are getting #Error is because everything single part of the
expression gets evaluated so your sum gets evaluated. You can't detect the
#Error because this is happening due to an error. You you need to do pass
the field to your GetSumResult and have it do the calculation so that you
don't do any invalid arithmetic.


--
Bruce Loehle-Conger
MVP SQL Server Reporting Services

[quoted text, click to view]

AddThis Social Bookmark Button