CALCSUM showing incorrect value.

rahul_jnk
Member Posts: 61
Hi all,
I have an Amount tendered field in a table which when computed using CALCSUM function shows a different amount than when I manually sum the columns. Anybody knows of any solution to this?
Regards,
Rahul.
I have an Amount tendered field in a table which when computed using CALCSUM function shows a different amount than when I manually sum the columns. Anybody knows of any solution to this?
Regards,
Rahul.
0
Best Answer
-
Hi all,
I have an Amount tendered field in a table which when computed using CALCSUM function shows a different amount than when I manually sum the columns. Anybody knows of any solution to this?
Regards,
Rahul.
Go into object designer for this table (I think it's Trans. Payment Entry) , open Key sand show all columns then untick "MaintainSIFTIndex" for the key (or keys) that have "Amount Tendered" in the SumIndexFields column.
Save the table, reopen it then retick the field and save again.
This will drop the indexed view and rebuild it.David Singleton2
Answers
-
Hello,
Have you applied correct filters on your record before CALCSUMS ?0 -
Hi NavNab,
Yes filter is identical. Actually I wrote a code that loops through the records and sums the "Amount Tendered" field and one that uses CALCSUM("Amount Tendered") both are showing different values.
In reality with that filter there are no records. Table.count shows 0 but CALCSUM is somehow getting value from somewhere.
0 -
Share your code, this will help understand the problem0
-
here it is..
paymententry.SETRANGE("Statement Code",'xxxxx');
paymententry.SETRANGE("Tender Type",'1');
paymententry.SETRANGE("Z-Report ID",'');
IF paymententry.FINDSET THEN REPEAT
amt += paymententry."Amount Tendered";
UNTIL paymententry.NEXT = 0;
paymententry.CALCSUMS("Amount Tendered");
MESSAGE(FORMAT(paymententry."Amount Tendered"));
MESSAGE(FORMAT(amt));0 -
try this
CLEAR(paymententry); paymententry.SETRANGE("Statement Code",'xxxxx'); paymententry.SETRANGE("Tender Type",'1'); paymententry.SETRANGE("Z-Report ID",''); IF paymententry.FINDSET THEN REPEAT amt += paymententry."Amount Tendered"; UNTIL paymententry.NEXT = 0; CLEAR(paymententry); paymententry.SETRANGE("Statement Code",'xxxxx'); paymententry.SETRANGE("Tender Type",'1'); paymententry.SETRANGE("Z-Report ID",''); paymententry.CALCSUMS("Amount Tendered"); MESSAGE(FORMAT(paymententry."Amount Tendered")); MESSAGE(FORMAT(amt));
1 -
I tried the code the results are same. I suspect database corruption or something, since issue is only with calcsum.0
-
Back in NAV4 I recall a bug causing this. It turned out the SIFT Bucket records were not deleted as they should. This was before NAV started using SQL Indexed Views.
Which version and build no. are you using?Regards
Peter0 -
Hi pdj, I'm using NAV 2016 & SQL Server 2014 Enterprise Edition.0
-
Back in NAV4 I recall a bug causing this. It turned out the SIFT Bucket records were not deleted as they should. This was before NAV started using SQL Indexed Views.
Which version and build no. are you using?
Check SIFT table records manually for primary key of "Payment Entry" table.Regards,
Yury0 -
Hi all,
I have an Amount tendered field in a table which when computed using CALCSUM function shows a different amount than when I manually sum the columns. Anybody knows of any solution to this?
Regards,
Rahul.
Go into object designer for this table (I think it's Trans. Payment Entry) , open Key sand show all columns then untick "MaintainSIFTIndex" for the key (or keys) that have "Amount Tendered" in the SumIndexFields column.
Save the table, reopen it then retick the field and save again.
This will drop the indexed view and rebuild it.David Singleton2 -
Thanks a lot David_Singleton. That worked.1
-
Thanks a lot David_Singleton. That worked.
Glad it fixed the problem. But ..
Be aware that this shouldn't happen, even though it does. Most often it is because of someone playing directly on the SQL server. But sometimes Navision manages to do this some how.
You should work to get to the cause of this, because it may affect other tables, and unfortunately the only way you typically find out is if you do what you just did to find this one. You can though write a SQL script that can go through and find any errors.David Singleton2 -
Just a word of warning: - indexed views (the structure used by NAV to calculate SIFTs these days) cannot be updated/changed manually, in separation to the table. They are internal SQL Server structures maintained by the SQL Server, not by NAV. The only thing NAV is doing is asking the SQL Server to create one.
If you have a discrepancy between the table and indexed view based on the table this usually means one of three things - the database corruption, the SQL Server fault, or the SQ Server hardware fault. Each one needs attention and remedy.
Rebuilding indexed views is only addressing the visible artefact of some deeper problem with your SQL installation. I'd strongly suggest you to run DBCC CHECKDB against your database(s), apply the most recent service pack to the SQL Server, and if you are already on the latest SP keep the backup of the wrong database and raise the issue with Microsoft.
What has happened shoud NOT happen in any circumstances, there is no user code which could contribute to such behaviour. What worse if it happened once it may happen again if you don't find and address the root cause. The next time it happens you may not notice and you may end up with incorrect amounts all over the database
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-033 -
Thank you Slawek_Guzek & David for your valuable advice.2
-
This version of Navision with the sift error was released on April the First.David Singleton0
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