Bug 40460 - [LOCALHELP] Calc IRR function error can be avoided but is not documented in help (see comment 11)
Summary: [LOCALHELP] Calc IRR function error can be avoided but is not documented in h...
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Documentation (show other bugs)
Version:
(earliest affected)
3.5.0 Beta2
Hardware: Other All
: lowest normal
Assignee: Olivier Hallot
URL:
Whiteboard: target:6.0.0.1 target:6.1.0
Keywords:
Depends on:
Blocks: HelpGaps-NewFeatures
  Show dependency treegraph
 
Reported: 2011-08-29 08:41 UTC by Antonio Arauzo
Modified: 2017-12-17 00:06 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet where IRR fails at cell G11 (71.00 KB, application/vnd.ms-excel)
2011-08-29 08:41 UTC, Antonio Arauzo
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Antonio Arauzo 2011-08-29 08:41:37 UTC
Created attachment 50663 [details]
Spreadsheet where IRR fails at cell G11

Internal Return Rate (IRR) function is widely used in financial tasks. In the attached spreadsheet example, LibreOffice gives "Err:523" at cell G11. However, the value 0.3775... is a solution. This solution is found by Gnumeric on the same spreadsheet file. By the way, MS Excel fails as LibreOffice does.

The green box checks that solution is correct. The check is based on the fact that IRR value must be an interest rate that makes the Net Present Value (NPV) of the number series equal to 0.
Comment 1 Björn Michaelsen 2011-12-23 12:37:27 UTC Comment hidden (obsolete)
Comment 2 Antonio Arauzo 2012-01-01 09:37:02 UTC
Tested on 3.5.0beta2. Still unable to calculate IRR on this example.
Comment 3 ign_christian 2013-06-21 05:12:00 UTC
I did some tests, found that we must enter "Guess" value to show the result.

> Internal Return Rate (IRR) function is widely used in financial tasks. In
> the attached spreadsheet example, LibreOffice gives "Err:523" at cell G11.
> However, the value 0.3775... is a solution. This solution is found by
> Gnumeric on the same spreadsheet file. By the way, MS Excel fails as
> LibreOffice does.

I guessed what you meant is cell G10 (not G11) = IRR(G11:G251;0), then correct result will be shown.

Tested on LO 4.0.4.2 (Win7 32bit)

Please REOPENED this bug if you can't reproduce this on latest stable release (3.6.6 or 4.0.4)
Comment 4 Antonio Arauzo 2013-09-07 15:23:47 UTC
Right, I meant G10.

It works correctly if introduced 0 as guess value in Version 4.0.2.2 (Build ID: 400m0(Build:2)).

However, if a result can be obtained without requiring the user to guess that the result is near 0 (as gnumeric does), it would be nicer. If I can I will have a look to the code, but I am quite busy now.
Comment 5 Joel Madero 2014-11-06 22:31:08 UTC
Needs confirmed by QA - moving to UNCONFIRMED. Thanks
Comment 6 raal 2014-11-07 18:42:21 UTC
I can confirm with Version: 4.4.0.0.alpha1+
Build ID: 04ea7b24ec1b5a027efa0b850f2bc3ac7116c52e
TinderBox: Linux-rpm_deb-x86_64@46-TDF, Branch:master, Time: 2014-11-06_00:02:40

Setting as NEW, excel 2010 show value 0,3775673823%
Comment 7 QA Administrators 2015-12-20 16:15:50 UTC Comment hidden (obsolete)
Comment 8 QA Administrators 2017-03-06 15:40:03 UTC Comment hidden (obsolete)
Comment 9 Dennis Roczek 2017-03-10 20:11:18 UTC
I still can REPRO the bug with:
Version: 5.3.0.3 (x64)
Build-ID: 7074905676c47b82bbcfbea1aeefc84afe1c50e1
CPU-Threads: 4; BS-Version: Windows 6.19; UI-Render: Standard; Layout-Engine: neu; 
Gebietsschema: de-DE (de_DE); Calc: group


@Winfried: something for you?
Comment 10 Winfried Donkers (retired) 2017-03-14 12:41:53 UTC
With the attached document IRR returns an error.
However, when you change the call to IRR to include an estimate and you give an estimate of 0.02 or less (including negative values), you get a result (0,3775673823%
, probably the same as Excel/Gnumeric).

When you look at the OpenFormula Standard, you will find that depending on the implementation of the IRR function a error as result is acceptable.

That needs some explanation:
IRR uses iterative algorithms to get a result, i.e. it starts with an estimate (either given in the call to IRR, or a default first estimate as written in the source code) and calculates backwards with that estimate to see how far wrong the estimate is. Depending on the error found, the algorithm adjusts its estimate and recalculates the error. This process repeats itself until the error is so small that is is acceptable. But -and this is what happens here- it is possible that for some combinations of data and estimate the error does not decrease and that the recalculations continue indefinitely -or until the algorithm has a maximum number of calculations within which an acceptable result must be found. If that maximum is exceeded, an error is returned.

The fact that Gnumeric and Excel do return a value and not an error with the attached document means that they either use a different algorithm (there are many possible algorithms for this type of calculation) and/or use a different starting estimate.

It is impossible to guarantee that a valid result will be found with IRR, but possibly it could try again with another starting estimate if the first estimate does not lead to a result. Even then there will be cases where an error is returned by IRR.

I will do some tests and either take this bug to myself to improve its behaviour, or set the status to 'RESOLVED/WONTFIX', as that is the actual situation.
Comment 11 Winfried Donkers (retired) 2017-03-16 12:52:24 UTC
Tests produces only a marginal improvement and adds extra complexity, so that is not a solution.

I have changed the title of the bug report as what really is missing, is help text explaining that:
- it is possible for IRR to fail and return Error 523, with "Calculation does not converge" in the status bar;
- this can be avoided by passing an(other) estimate to IRR.
Comment 12 Commit Notification 2017-12-16 23:59:30 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "libreoffice-6-0":

http://cgit.freedesktop.org/libreoffice/help/commit/?id=2d1dfbc702217bde0e208de8f969cdb1b4262f81&h=libreoffice-6-0

tdf#40460 Improve help for Calc IRR function
Comment 13 Commit Notification 2017-12-16 23:59:40 UTC
Olivier Hallot committed a patch related to this issue.
It has been pushed to "master":

http://cgit.freedesktop.org/libreoffice/help/commit/?id=8b0a4944747cde7395b36e53893d85dc8b07ee05

tdf#40460 Improve help for Calc IRR function