Grouping table by a field and finding sum in Dynamics NAV 2018

letayoknow
Member Posts: 3
I'd like to group a table by a field- employer code and then calculate the sum of a decimal field- total contribution in that group from C/AL code. Here's my table structure
How can I assign each employer code and the sum of the total contributions for that employer to variables from C/AL code
Employer No_ Total Contribution PRTEMP005022 1817.64 PRTEMP005022 1782 PRTEMP005022 2049.3 PRTEMP005022 1568.16 PR0000247148 47750.62 PR0000247148 47532.81 PU0000400011 5314.52 PU0000400011 5314.52 PU0000400011 17225.83 PU0000400011 4509.61 STRV00000000 6088.72 STRV00000000 4065.36 STRV00000000 2191.18 STRV00000000 3485.42 STRV00000000 4709.77
How can I assign each employer code and the sum of the total contributions for that employer to variables from C/AL code
0
Answers
-
1. Use temporary table to store calculated totals
2. Use Query to calculate total
3. Create flowfield in Employee table to calculate totals
4. Use MS Sql Query with dotnet0 -
Can you please share a sample code?0
-
IF Entry.FINDSET THEN REPEAT IF TotalTemp.GET(Entry.Code) THEN BEGIN TotalTemp.Amount += Entry.Amount; TotalTemp.MODIFY; END ELSE BEGIN TotalTemp.Code := Entry.Code TotalTemp.Amount := Entry.Amount; TotalTemp.INSERT; END; UNTIL Entry.NEXT = 0;
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