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!
-- 1
CASE WHEN denomiator = 0 THEN 0 ELSE numerator/denominator AS YourResultColmn
-- 2
COALESCE(numerator/NULLIF(denominator,0),0) AS YourResultColumn
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