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

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Check for zero of null value in SSRS 2005 in the S

Author  Topic 

dbrune
Starting Member

2 Posts

Posted - 2012-10-09 : 13:32:40
This is a question that I think is more a problem with SSRS than anything else. I have created a select statement that contains a lot of calculated values that are then grouped for a report and I would like to check for nulls and zeros in the denominator and return a 0 if that is found. I DO NOT want to put it in the Report itself but want to do it in the SQL Select statement. Does anyone know if this is possible and how to do it? Using IF THEN, CASE or other expressions does not seem to work!

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-09 : 14:26:16
Either of the following should work:
-- 1
CASE WHEN denomiator = 0 THEN 0 ELSE numerator/denominator AS YourResultColmn

-- 2
COALESCE(numerator/NULLIF(denominator,0),0) AS YourResultColumn
Go to Top of Page

dbrune
Starting Member

2 Posts

Posted - 2012-10-10 : 17:18:22
When I use these formulas I am getting the message "invalid or missing expression". I am not writing inline SQL but using the graphical query designer.

CASE WHEN Table1.Field1 = 0 THEN 0 ELSE Table2.Field2 / 1000 * Table1.Field1
Go to Top of Page
   

- Advertisement -