@carlbrianhadi.... The following works by coincidence (explained below) with your example.
Array-enter (press ctrl+shift+Enter instead of just Enter) the following formula into D4, then copy D4 and paste into D5:D23:
It works only for your example and only by coincidence because your example requires a "guess" parameter (-1%) in order to coerce XIRR to return a reasonable result. For some other examples, a "guess" of -1% might not work.
Also, we use IFERROR to mask a #NUM error in D5. That #NUM error is reasonable since a mathematical calculation of the IRR is (0/126000)^35 - 1 = 0^35 - 1 = -100%. Apparently, Excel XIRR does not recognize the special case. And in general, the IRR cannot be -100%, since NPV = 126000/(1-100%)^0 + 0/(1-100%)^1 is not computable.
But the use of IFERROR might mask other #NUM and #DIV/0 errors, which normally requires a (different) "guess" parameter to remedy the error, if that is even possible.
It should also be noted that Excel XIRR sometimes returns bogus numerical results, which would go undetected. In particular, XIRR might return about +/-2.98E-09, which appears to be zero unless you format the cell as Scientific. In my experience, that particular result should be interpreted the same as #NUM or #DIV/0, namely: we should provide a (different) "guess" parameter.
The best way to detect bogus numerical results is calculate the NPV and ensure that it is "relatively close to zero". That is purposely vague, to imply that the test is fraught with error. Moreover, Excel XNPV does not allow negative discount rates; a defect, IMHO. We would need to use a SUMPRODUCT expression to calculate the (X)NPV ourselves. Ostensibly, that formula would be (X1 = result of XIRR):
=SUMPRODUCT(C4:C23/(1+X1)^((A4:A23-A4)/365))
But of course, that needs to be embellished and array-entered in a manner similar to the XIRR formula above.
Bookmarks