Sum in RDLC (sum(ReportItems!Amount.value) & Code.BlankZero)
jdvb
Member Posts: 4
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:
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:
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
0
Comments
-
May be, you should try a hidden column with a RunningValue function.
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/New kits on the blog: https://massivedynamicsblog.wordpress.com0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
