Sum in RDLC (sum(ReportItems!Amount.value) & Code.BlankZero)

jdvbjdvb Member Posts: 4
edited 2014-05-27 in NAV Three Tier
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
Sign In or Register to comment.