views:

47

answers:

1

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-

A: 

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.

Brian Gideon
That worked thanks!
Eric Brown - Cal
For anyone who follows, you actually need to do this to handle the case that there are zero non zero columns ) IN this case I'm doing money.... =FormatCurrency( iif( Sum( IIf(Fields!SixMonEarn.Value > 0, 1, 0) ) , Sum(Fields!SixMonEarn.Value > 0) / Sum(IIf(Fields!SixMonEarn.Value > 0, 1, 0)), 0 ) )
Eric Brown - Cal
@Eric: Nice catch.
Brian Gideon
Corrected for minor typo.=FormatCurrency( iif( Sum( IIf(Fields!SixMonEarn.Value > 0, 1, 0) ) , Sum(Fields!SixMonEarn.Value ) / Sum(IIf(Fields!SixMonEarn.Value > 0, 1, 0)), 0 ) )
Eric Brown - Cal

related questions