Adding a total to a NAV report
wml
Member Posts: 2
Hi,
I am currently editing a Packing List report in the NAV development environment (with report builder). The last thing I need to do is to add several totals to the report (for example total weight).
The weight of each line in the packing list is calculated by Quantity*(Weight of 1 item). I cannot manage to calculate the total weight, since the weight of each line is not stored anywhere (so something as easy as SUM(weight) does not work).
Is there maybe some way to keep track of a running total with a few lines of code, which I print at the bottom of the report in the end?
Thanks in advance!
I am currently editing a Packing List report in the NAV development environment (with report builder). The last thing I need to do is to add several totals to the report (for example total weight).
The weight of each line in the packing list is calculated by Quantity*(Weight of 1 item). I cannot manage to calculate the total weight, since the weight of each line is not stored anywhere (so something as easy as SUM(weight) does not work).
Is there maybe some way to keep track of a running total with a few lines of code, which I print at the bottom of the report in the end?
Thanks in advance!
0
Best Answers
-
On the "OnAfterGetRecord" of the DataItem that is processing the lines, you can add
TotalWeight += Weight;
Being TotalWeight a decimal field that u declare on the global variables and Weight the field that is returned from your table (or the equation you just described).
Then just send him to the report.5 -
That is possible but a simpler option is to calculate a "Line Weight" value for each line in C/AL and then include this in the dataset - then you can use SUM in RDLC. As it's for a Packing List report it won't add much to the size of the dataset so you won't have problems about it getting too big or slow.
@LCosta you beat my post by 1 min
@wml both my solution and LCosta's solution amount to the same thing really - go with either option5
Answers
-
On the "OnAfterGetRecord" of the DataItem that is processing the lines, you can add
TotalWeight += Weight;
Being TotalWeight a decimal field that u declare on the global variables and Weight the field that is returned from your table (or the equation you just described).
Then just send him to the report.5 -
That is possible but a simpler option is to calculate a "Line Weight" value for each line in C/AL and then include this in the dataset - then you can use SUM in RDLC. As it's for a Packing List report it won't add much to the size of the dataset so you won't have problems about it getting too big or slow.
@LCosta you beat my post by 1 min
@wml both my solution and LCosta's solution amount to the same thing really - go with either option5 -
I hope the above suggestion might resolve your issue but in case If it didn't then try using VB code in RDLC by creating some custom functions and do the calculation inside the functions. keep in mind to clear the variables whenever the group changes.Software Developer,
Archerpoint India Pvt. Ltd,Chennai.0 -
Thanks for the input everyone! I went with the solution proposed by Kishorm and it seems to work fine. Since I'm still new to C/AL coding, it was very useful to know where to add my code, so thanks for that as well LCosta
1
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

