Search code examples
reportviewerrdlcreportviewer2008

Trying to calculate the Average of the non zero rows in a column in an RDLC


Is there any way to caculate the average of the non zero rows only for a column of data in a table in an RDLC for Microsoft report viewer?

ie 0 0 0 5 5 = 5 not 2

I tried Count( fields.n.value > 0 ) to get the count of non zero rows, but it returned the count of all rows.

Thanks!

Eric-


Solution

  • Try this:

    =Sum(Fields!n.Value > 0) / Sum(IIf(Fields!n.Value > 0, 1, 0))
    

    Notice how the average is computed manually by summing all values then dividing by another sum that mimics a specialized count mechanism.