Report: Calculating Sum with duplicate values in Dataset

hornster
Member Posts: 3
Hi!
Got a bit of a problem in a report on nav 2009 r2
Got a report where 2 data items (customer ledg entry and g/l entry) are grouped. They are grouped on document no. from customer ledger entry.
Here I got a simplified version of the table structure I'm currently using:
One solution I found here(Darentan's post)
basically, I put the table into a list and use a custom function:
I'd then use the value of the sum_of_salesLCY variable in the sum text box in the footer, but I just get 0 as value. After some experimenting I found out that it actually works, but the problem is that the sum would be displayed in the next "group" of the list.
list group 1 -> sum = 0
list group 2 -> sum = actual sum of list group 1
so... thats my problem... is there any way to get this method to work?
Any other methods to correctly display/calculate the sum?
I appreciate any help I can get
Sorry if this mess of a text is a bit confusing.
Got a bit of a problem in a report on nav 2009 r2
Got a report where 2 data items (customer ledg entry and g/l entry) are grouped. They are grouped on document no. from customer ledger entry.
Here I got a simplified version of the table structure I'm currently using:
grp_header.|Doc_no|......|Sales_LCY.|Amount_LCY. detail.....|......|Acc_No|..........|........... tablefooter|......|......|Sum(Sales)|Sum(Amount)Now, what I want (like I got it in the classic report) is to sum up the distinct values of Sales LCY and Amount LCY from the group headers. In RTC, however, the sum is obviously calculated through the dataset, and there I got several duplicate entries, since I got the a doc no entry for each acc no entry, and so the sum is calculated with all those duplicates.
One solution I found here(Darentan's post)
basically, I put the table into a list and use a custom function:
Public sum_of_salesLCY As Integer Public Function SumUp(ByVal Value As Integer) sum_of_salesLCY = sum_of_salesLCY + Value End FunctionIn a text field next to sales/amount lcy in the group header I use this function, with the value of the textfield containing sales lcy as parameter.
I'd then use the value of the sum_of_salesLCY variable in the sum text box in the footer, but I just get 0 as value. After some experimenting I found out that it actually works, but the problem is that the sum would be displayed in the next "group" of the list.
list group 1 -> sum = 0
list group 2 -> sum = actual sum of list group 1
so... thats my problem... is there any way to get this method to work?
Any other methods to correctly display/calculate the sum?
I appreciate any help I can get

Sorry if this mess of a text is a bit confusing.
0
Comments
-
I don't know if this will help you, but let me try.
When something gets difficult using SSRS Layout designer, what I do as a last resource solution is that I calculate in this case the SUM you are looking for in NAV and store it in a global variable. Then I just add this global variable to a column in my dataset and then I can easily use it in my report layout.0 -
I thought about that as well, but as you said - last resort. Thanks though0
-
From a performance point of view it is also better to do the SUM in NAV.
But notice that you can always place the scope at the end of the expression i.e "Sum(Fields!Amount.Value, "Scope").
This way you can be very specific on what sum you show, but you cannot show a Child Group Sum in a Parent Group.
So to me it looks like you want a ChildGroup Sum in the ParentGroup, in your case Tablix footer which is the whole dataset if not filtered.
/Claus LundstrømClaus Lundstrøm | MVP | Senior Product Manager | Continia.com
I'm blogging here:http://mibuso.com/blogs/clausl and used to blog here: http://blogs.msdn.com/nav
I'm also offering RDLC Report Training, ping me if you are interested. Thanks to the 700 NAV developers that have now already been at my training. You know you can always call if you have any RDLC report issues :-)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions