calcsums
charles.roos
Member Posts: 60
Hi, can you confirm that i understand correctly following:
1. Table1 definition:
field1
field2
field3
field4
key: (field2, field3) sumindexfield: field4
2. Code to calculate field4 total sum:
setcurrentKey( field2, field3 )
setfilter( field1, value1)
setfilter( field2, value2)
calcsums( field4 )
message( Table1.field4 )
Does this code outputs correct Table1.field4 total sum?
The key of the sumindex field didn't get filters on field3, and "field1" which is outside of the key got also a filter. Does it return correct sum for me?
1. Table1 definition:
field1
field2
field3
field4
key: (field2, field3) sumindexfield: field4
2. Code to calculate field4 total sum:
setcurrentKey( field2, field3 )
setfilter( field1, value1)
setfilter( field2, value2)
calcsums( field4 )
message( Table1.field4 )
Does this code outputs correct Table1.field4 total sum?
The key of the sumindex field didn't get filters on field3, and "field1" which is outside of the key got also a filter. Does it return correct sum for me?
0
Comments
-
Hi
Nav return good sum, only in case when Field1 is in PrimaryKey of that table, in other case Nav give You error that You use wrong key for calcsum.
Regards0 -
Hi charles.roos
Yes it does. I made an simple example to check it, when I saw JedrzejT answer:OBJECT Table 59999 test3 { OBJECT-PROPERTIES { Date=08-06-12; Time=16:03:21; Modified=Yes; Version List=; } PROPERTIES { } FIELDS { { 1 ; ;No1 ;Integer } { 2 ; ;No2 ;Integer } { 3 ; ;No3 ;Integer } { 4 ; ;Value ;Decimal } } KEYS { { ;No1 } { ;No2,No3 ;SumIndexFields=Value } } CODE { BEGIN END. } } OBJECT Form 59999 TEST { OBJECT-PROPERTIES { Date=08-06-12; Time=16:05:11; Modified=Yes; Version List=; } PROPERTIES { Width=9790; Height=7480; TableBoxID=1000000000; SourceTable=Table59999; } CONTROLS { { 1000000000;TableBox;220 ;220 ;9350 ;5500 ;HorzGlue=Both; VertGlue=Both } { 1000000001;TextBox;0 ;0 ;1700 ;0 ;ParentControl=1000000000; InColumn=Yes; SourceExpr=No1 } { 1000000002;Label ;0 ;0 ;0 ;0 ;ParentControl=1000000001; InColumnHeading=Yes } { 1000000003;TextBox;0 ;0 ;1700 ;0 ;ParentControl=1000000000; InColumn=Yes; SourceExpr=No2 } { 1000000004;Label ;0 ;0 ;0 ;0 ;ParentControl=1000000003; InColumnHeading=Yes } { 1000000005;TextBox;0 ;0 ;1700 ;0 ;ParentControl=1000000000; InColumn=Yes; SourceExpr=No3 } { 1000000006;Label ;0 ;0 ;0 ;0 ;ParentControl=1000000005; InColumnHeading=Yes } { 1000000007;TextBox;0 ;0 ;1700 ;0 ;ParentControl=1000000000; InColumn=Yes; SourceExpr=Value } { 1000000008;Label ;0 ;0 ;0 ;0 ;ParentControl=1000000007; InColumnHeading=Yes } { 1000000009;CommandButton;2530;6710;2200;550; HorzGlue=Right; VertGlue=Bottom; Default=Yes; PushAction=LookupOK; InvalidActionAppearance=Hide } { 1000000010;CommandButton;4950;6710;2200;550; HorzGlue=Right; VertGlue=Bottom; Cancel=Yes; PushAction=LookupCancel; InvalidActionAppearance=Hide } { 1000000011;CommandButton;7370;6710;2200;550; HorzGlue=Right; VertGlue=Bottom; PushAction=FormHelp } { 1000000012;CommandButton;7370;5940;2200;550; CaptionML=ENU=Calculate; OnPush=BEGIN Rec.SETCURRENTKEY(No2, No3); Rec.SETRANGE(No1,1,10); Rec.SETRANGE(No2,1,10); Rec.CALCSUMS(Value); MESSAGE('%1', Rec.Value ); END; } } CODE { BEGIN END. } }
Inserted data:
No1 No2 No3 Value
1 1 1 100,00
2 12 10 100,00
3 3 3 100,00
100 1 1 1 000,00
Returned Value:
200
Have a good day...0
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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 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