Apache OpenOffice (AOO) Bugzilla – Issue 92774
ODFF: NPV() must evaluate arguments in the order given and row-wise
Last modified: 2017-05-20 10:30:58 UTC
In NPV() the order of values is significant and affects the result. Evaluation of arguments must be in the order given and range reference and array arguments must be evaluated row-wise starting from top left to comply with ODFF and be compatible with other spreadsheet applications.
Created attachment 55754 [details] test case, result in D6 is wrong
Created attachment 62428 [details] Patch 1, small change.
As discussed on IRC, a row-wise value iterator may be better suited that then could be reused in other statistical functions needing to evaluate data row-wise. The challenge is to not lose the performance benefit of the ScValueIterator that accesses the data column-wise as it is stored internally. Setting up an array of ScValueIterators, one per column, comes to mind; that then could be iterated through for each row. Just a quick idea..
Take a look at ScHorizontalCellIterator, that combined with the functionality of ScValueIterator might be it.
Created attachment 62898 [details] Another test case.
I found another problem with NPV(), see the attached file i92774_NPV_singleref.xls, in Excel, the results of C4 and D4 are the same, but in OOo, they are not. Please check this.
Created attachment 63261 [details] Patch 2.
A patch is a patch.
With a little modification. In cws dr78: changeset 297b5255c27a http://hg.services.openoffice.org/cws/dr78/changeset/297b5255c27a M sc/inc/column.hxx M sc/inc/dociter.hxx M sc/inc/document.hxx M sc/inc/table.hxx M sc/source/core/data/dociter.cxx M sc/source/core/tool/interpr2.cxx You can observe the progress and possible integration date of CWS dr78 at http://tools.services.openoffice.org/EIS2/cws.ShowCWS?Path=DEV300%2Fdr78
Reassigning to QA for verification.
Seen ok in cws dr78 -> verified