65.9K
CodeProject is changing. Read more.
Home

Conditional Sum for Rdlc (aka ReportViewer)

starIconstarIconstarIconstarIconstarIcon

5.00/5 (4 votes)

Jul 13, 2010

CPOL
viewsIcon

41098

Code for summing by group in a RDLC report

Go to Report>Report Properties>Code and insert:
Public Function ConditionalResult(checkField as Field, compareValue as Object, returnValue as Field) As Decimal
    IF checkField.Value <> compareValue
        Return 0 
    else 
        Return returnValue.Value
    end if 
End Function
To insert the group sum, in an aggregrate field (ie, footer), add code similar to:
=Sum(code.ConditionalResult(Fields!Validated, true, Fields!TransactionAmount))