How to do that....Item.CALCSUMS("Sales (LCY)")???

voodoo
Member Posts: 82
I have a report and I want to do Item.CALCSUMS("Sales (LCY)"), but Sales (LCY) has complicated CalcFormula, and in Item table there aren't a key for that filter in CalcFormula.
Anyone knows solution for that???
Thnx
Anyone knows solution for that???
Thnx
misha fka voodoo
0
Comments
-
Why do you think you need a key in the Item table. :?
Flowfields are only calculated if the keys and sumindexes are present, otherwise you will receive a runtime error.
Have you tried to use it? What error do you get (If any)0 -
This is the error:The sum of the values in the Sales (LCY) field cannot be calculated because the currnet key does not contain all the fields being filtered.
You must select a key that contain all the fields in the filter. The order of the field is unimportant.
Filters: Date filter.....
Table: Item
Key Fileds: No.
???misha fka voodoo0 -
Ah, I thought it would be something like that.
The only way to get this to work is to create the key Navision asks for.
Nomaly this flowfield is calculated from the Value Entries.
Have you checked if the key is present? Maybe it is not active.
Otherwise just create the key in the Value Entry table.0 -
Aha, i thought that i need to create a key in Item table, and that confuse me, because these fields are not exist in Item table.misha fka voodoo0
-
-
Well, still have the same problem.......let me explain.......In report one of dataitem is Item, and in OnAfterGetRecord I want to do CalcSums(Sales (LCY), in value entry table I checked key with fields in CalcFormula of Sales (LCY), but still have the same message.misha fka voodoo0
-
-
You mean in Value Entry table??? Yes, in VE table Sales Amount (Actual) is SumIndexfield
....
Key in VE:
Item No.,Item Ledger Entry Type,Global Dimension 1 Code,Global Dimension 2 Code,Location Code,Drop Shipment,Variant Code,Bin Code,Posting Date
SumIndexFiled: Sales Amount (Actual)
CalcFormula for Sales (LCY) in Item table:
Sum("Value Entry"."Sales Amount (Actual)" WHERE (Item Ledger Entry Type=CONST(Sale),Item No.=FIELD(No.),Global Dimension 1 Code=FIELD(Global Dimension 1 Filter),Global Dimension 2 Code=FIELD(Global Dimension 2 Filter),Location Code=FIELD(Location Filter),Drop Shipment=FIELD(Drop Shipment Filter),Variant Code=FIELD(Variant Filter),Bin Code=FIELD(Bin Filter),Posting Date=FIELD(Date Filter)))
What is the problem with this
:oops:misha fka voodoo0 -
Could you please give some details about the code you have created?
I am affraid the error is in the way the calcsums is used, not in the key (anymore).0 -
Well, like I said before, only code is in OnAfterGetRecord(Item - Dataitem):
CalcSums(Sales (LCY))misha fka voodoo0 -
Try to replace Calcsums by Calcfields
Sorry I did not see that earlier. I need weekend I guess0 -
It works with Calcfields, but can u tell me what is the problem with Calcsums???
Tnhx, and sorry if i'm interrupting you, I know the weekend is so closemisha fka voodoo0 -
Calcsums is intended to calculate the sums of more than one record in a filter.
e.g.
ValueEntry.SETCURRENTKEY("Item No.");
ValueEntry.SETRANGE("Item No.", '10000');
ValueEntry.CALCSUMS(Amount);
this calculates the total amount of all valueentries where Item No. = 10000
NOTE: you need to define a key that contains all fields you filter on.
Calcfields is used for flowfields
e.g.
Item.GET('10000');
Item.CALCFIELDS(Amount);
If the flowfield relates to the value enties the result is the same as in example 1.
I hope this answers your question.0 -
Yes this is the answer, but I need to calculate the sums for all items for selected classes, and result which I get isn't good(with calcfields)misha fka voodoo0
-
I'm not sure but I think that You can't use CalcSums with FlowField. You should use something like this:
Declare a variable, for example "Total" and then:
total:=0;
table.Setrange(....);
...
...
IF table.find('-') THEN
repeat
table.calcfields("Sales(LCY)");
total:=total+table."Sales(LCY)";
until table.next()=0;
I think it should work ok.0 -
This is true.
You can also filter on the valueentries for all your items and do the calcsums,
ValueEntry.SETCURRENTKEY("Item No.");
ValueEntry.SETRANGE("Item No.", '10000', '50000');
ValueEntry.CALCSUMS(Amount);0 -
May be that problem is, that you want to use calcsums on flowfields, and it is not possible... :-) if you need sums of flowfields, you need to use the flowfield definition to apply filters to the slave table and call calcsums to this table, not to the master...
example: if the flowfield definition isSum("Value Entry"."Sales Amount (Actual)" WHERE (Item Ledger Entry Type=CONST(Sale),Item No.=FIELD(No.),Global Dimension 1 Code=FIELD(Global Dimension 1 Filter),Global Dimension 2 Code=FIELD(Global Dimension 2 Filter),Location Code=FIELD(Location Filter),Drop Shipment=FIELD(Drop Shipment Filter),Variant Code=FIELD(Variant Filter),Bin Code=FIELD(Bin Filter),Posting Date=FIELD(Date Filter)))
You need to open "Value Entry" table, apply all filters as are in the definition and add you own filters you need (filtered fields must be in some key), and call "Value Entry".CALCSUMS("Sales Amount (Actual)").
Than you will have sums, you need...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