SQL 2005 Reporting Services if check for null

reporting-services, reportingservices-2005, sql-server-2005

Solution

I would try using ISNULL(fieldname, 0) when querying for your dataset.

If you are connecting to a datasource without an ISNULL operator (ie. Oracle) then try using COALESCE(fieldname, 0), which iSeries, oracle and sql all support.

Problem

In SSRS 2005 I have a table with a dataset linked to it. I want to check if the value of a field is null and if it is not null then format the data to make sure it has one decimal place and add a % sign etc. This is my expression on the field/column: ``` =iif(IsNothing(Fields!COL01.Value), "" ,Format(CDbl(Trim(Replace(Fields!COL01.Value, "%", ""))), "N1") + "%") ``` It doesn't seem to work though when the data is null (It works fine if there is data). The report displays but the field shows up as #ERROR. I think its checking to see if both cases are valid even though its null. I'm trying to use the if statement to avoid formating a null.

Original source