Tsql – SQL Server 2005 Reporting Services: How to count rows that are not null? Any hints for calculating totals

groupingreportreporting-servicessql-server-2005tsql

Using Reporting Services in SQL Server 2005: Is there a way to count only records that are not null; similar to "COUNTA" in Excel? I would think this would be very simple process, but nothing I have tried has worked. For example, I have tried using the following expression for "Completed", which is one column I am trying to count:
=count(IIF(Fields!Completed.Value="END"))
However, this throws the "wrong number of arguments" error. "Completed" will have a value of "End" or be null.

If necessary, I can try to work this into my SQL query, but the query is already incredibly complicated.

Also, I've found very little documentation for how to calculate report totals, and how to total from groups. Would anyone have any recommendations on what to use as a reference?

Update: upon further inspection, the expression =SUM(IIF(IsNothing(Fields!Completed.Value),0,1)) DOES indeed return the appropriate number of records. I made the mistake of thinking that the report would tally up the number of records in the actual report with "end" for a value. Since the report groups on "Completed", "End" only shows up once in the report for each unique ID (also being grouped on, above Completed). So I really need to be counting (suming?) based on subtotals…if that's even possible.

Best Answer

=SUM(IIF(IsNothing(Fields!Completed.Value),0,1))