Sub topic 13
How Excel solves for IRR and when it fails
This chapter assumes you can already enter IRR and XIRR formulas and know that IRR is the rate that sets NPV to zero. It explains how Excel finds that rate, why the search sometimes fails, and what to do when it does.
Why IRR needs a search
NPV has a direct formula. IRR does not. You must find the rate r that solves this equation:
NPV(r) = CF0 + CF1/(1+r) + CF2/(1+r)^2 + ... + CFn/(1+r)^n = 0
For more than four periods, there is no algebraic solution in general. Excel therefore makes a starting guess and improves it step by step. This is called iterative solving.
The iteration, step by step
Excel does not publish its exact algorithm. It behaves like a Newton-style root finder, which works like this:
- Start at a guess rate
r0. The default guess is 10% (0.1). - Compute NPV at
r0, and the slope of the NPV curve atr0. - Follow the slope down to where it would cross zero. That point is the next rate,
r1 = r0 - NPV(r0) / slope(r0). - Repeat until NPV is close enough to zero, or the iteration limit is reached.
The documented limits differ by function:
| Function | Iteration limit | Stops when | On failure |
|---|---|---|---|
| IRR | 20 tries | Result is accurate within 0.00001% | `#NUM!` |
| XIRR | 100 tries | Result is accurate within 0.000001% | `#NUM!`, and occasionally a value near zero such as 2.98E-09 |
The following Python sketch runs the same idea on the cash flows used earlier in this tutorial. It shows how quickly the search closes in when the curve is well behaved.
flows = [-10000, 3000, 4000, 4000, 3000]
def npv(r):
return sum(cf / (1 + r) ** t for t, cf in enumerate(flows))
def slope(r):
return sum(-t * cf / (1 + r) ** (t + 1) for t, cf in enumerate(flows))
r = 0.10 # Excel's default guess
for step in range(1, 8):
r = r - npv(r) / slope(r)
print(f"step {step}: rate = {r:.6f}, NPV = {npv(r):.6f}")The rate settles near 14.9% within a few steps, and the printed NPV shrinks toward zero. In Excel, =IRR(B3:B7) returns the same rate for this project.
When the search fails
Most failures come from the cash flows, not from Excel.
No sign change
IRR needs at least one negative and one positive cash flow. If every value has the same sign, NPV never crosses zero at any rate, and Excel returns #NUM!. A common cause is a sign-convention slip, such as entering the investment as a positive number.
The guess is far from the root
Newton-style steps can overshoot when the curve is steep or flat. A bad guess can send the search to a rate below -100%, where (1+r) is zero or negative. The search then fails or lands on a different root.
Very high or very low returns
A project that returns 500% per period, or one that loses almost everything, puts the root far from 10%. Twenty iterations may not be enough to reach it from the default guess.
Multiple roots
When cash flows change sign more than once, NPV(r) can cross zero at several rates. The next chapter covers what this means for decisions. Here the point is mechanical: the guess decides which root Excel finds.
B3: -100
B4: 230
B5: -132
Both rates make NPV zero (10% and 20%):
=NPV(0.1, B4:B5) + B3
=NPV(0.2, B4:B5) + B3
The guess steers the search; compare the results:
=IRR(B3:B5, 0.05)
=IRR(B3:B5, 0.3)Whichever rate each formula returns, verify it with the NPV check on the next line. Do not assume the answer is the only one.
Blank cells and text
IRR ignores text, logical values, and empty cells inside a range. A blank cell in the middle of a series is not treated as a zero cash flow, so the periods after it shift earlier. If a period has no cash flow, enter an explicit 0.
For XIRR, a different set of rules applies:
- If any date is text, you get
#VALUE!. - If the values and dates ranges have different sizes, you get
#NUM!. - If any date is earlier than the first date, you get
#NUM!. - Dates with a time portion are truncated to whole days.
Supplying a guess
The guess is the second argument of IRR and the third of XIRR. It is a rate per period for IRR and an annual rate for XIRR. Choose a guess close to where you expect the answer.
Monthly cash flows in B3:B38, expected annual return about 15%,
so a monthly guess of about 1.2%:
=IRR(B3:B38, 0.012)
Dated cash flows, expected annual return about 40%:
=XIRR(B2:B6, A2:A6, 0.4)A common mistake is passing an annual guess to IRR when the cash flows are monthly. The guess then sits far from the monthly root and may cause a failure.
A troubleshooting workflow
When IRR or XIRR fails or looks wrong, work through these steps in order.
- Check the signs. Confirm there is at least one negative and one positive value.
- Check the layout. Confirm there are no blanks inside the range, no text dates, and equal-length ranges.
- Try other guesses. A single failure at the default guess does not mean no solution exists.
- Plot the NPV profile. See where the curve crosses zero, then use a guess near that point.
- Verify the result. Compute NPV or XNPV at the returned rate and confirm it is near zero.
Here are formulas for the checks in steps 1, 3, and 5:
Signs present (TRUE or FALSE):
=AND(COUNTIF(B3:B7,">0")>0, COUNTIF(B3:B7,"<0")>0)
Count of sign changes between neighbouring flows:
=SUMPRODUCT(--(SIGN(B3:B6)*SIGN(B4:B7)<0))
Try a range of guesses in D3:D8 and show the result or "fail":
=IFERROR(IRR($B$3:$B$7, D3), "fail")
Verify the result:
=NPV(IRR(B3:B7), B4:B7) + B3More than one sign change warns you that several IRRs may exist. In the sign-change count, a zero cash flow breaks the comparison, so use it only on series without zeros.
If none of the guesses works, build the NPV profile from the earlier chapter and read the crossing point off it. You can also use Goal Seek to set NPV to 0 by changing a rate cell, but it has the same dependence on the starting value.
What the iteration limits mean in practice
Reaching the limit does not prove that no IRR exists. It proves only that the search from that guess did not converge within the allowed steps. Equally, convergence does not prove the answer is the only one or the economically relevant one. Always separate two questions:
- Did Excel find a root?
- Is that root the one my decision should rest on?
The first is a numerical question answered by the NPV check. The second is a modelling question answered by looking at the sign pattern and the NPV profile.
Exercise
A model has 24 monthly cash flows in B3:B26, with a large outflow in B3. =IRR(B3:B26) returns #NUM!. List the checks you would make, in order, and say what formula you would use to confirm the answer once you have one.
Show answer
First, confirm the signs: at least one negative and one positive value, using COUNTIF with ">0" and "<0". Next, check for blanks, text, or a missing outflow caused by a sign slip. Then retry with a monthly guess, for example =IRR(B3:B26, 0.01), and try several guesses, since the default 10% per month may be far from the root. If it still fails, plot the NPV profile to see where it crosses zero and choose a guess near that point. Once a rate is returned, confirm it with =NPV(IRR(B3:B26, 0.01), B4:B26) + B3, which should be near zero. Also count sign changes, because more than one means other IRRs may exist.