I am trying to develop a neat solution for transheader and transfooter where the body of a report does not have to be altered in order to aquire the totals.
What I have done:
In the footer I call Code.SetTotal(Sum(ReportItems!Amount.value))
In the header I call Code.GetTotal
The mentioned functions are pritty simple:
Private running As Double = 0
Public Function SetTotal(ByVal val As Double) As Double
running = val
Return val
End Function
Public Function GetTotal() As Double
Return CDec(running)
End Function
Apart from the CDec, that is AFAIK default code.
Now, here is my issue:
The default also makes use of Code.BlankZero. When this occurs in Fields!Amount, the Sum will return Error.
A solution for this issue is to set the hidden property of the Amount field to '=(Fields!Amount.value=0)', which works when there is no formatting to be shown for the specified field, like border lines etc. I am no expert in VB, though would imagine it to be possible to send the ReportItems!Amount.value to some function to return the total correctly ignoring blank values.
Basically a Sum function that does not break on the usage of Code.BlankZero.
Can anyone help me make such a thing?
I'd think something like:
Public Function SetTotal(ByVal val As Array) As Double
Foreach amt in val
If amt <> 0 Then
running += val
End if
Next
Return running
End Function
Comments
See, for example, https://blogs.msdn.microsoft.com/nav/2010/03/17/transfooter-and-transheader-functionality-in-rdlcssrs-reports/ or https://massivedynamicsblog.wordpress.com/2015/12/05/how-to-implement-carryover-in-rdlc-report-layouts/