Sub topic 11
Using XNPV
XNPV is the NPV function for cash flows that fall on specific calendar dates. This chapter assumes you know what NPV measures, how Excel's NPV function treats the first cash flow, and how to enter real dates in cells. Here you will see how XNPV computes its result, how to lay out the inputs, and which errors to expect.
Why XNPV exists
NPV assumes cash flows are evenly spaced and that the first value is one full period away. Real projects rarely work that way. An invoice is paid on the 17th, a loan draws down mid-quarter, and a dividend arrives 41 days after the last one.
XNPV fixes this by taking a date for every cash flow. It measures time in days instead of counting periods, so uneven gaps are handled correctly.
The syntax
=XNPV(rate, values, dates)rateis an annual discount rate. Do not convert it to a monthly or daily rate.valuesis the range of cash flows.datesis the range of dates, in the same order and with the same count asvalues.
The first date in dates is the valuation date, and it is t=0. XNPV does not discount the first cash flow at all. This differs from NPV, which discounts its first value by one period. As a result, XNPV needs no "add the t=0 cash flow outside the function" step.
The formula behind it
For cash flow CF_i on date d_i, with the first date d_1:
PVi = CFi / (1 + rate)^((di − d1) / 365)
XNPV sums these present values. The divisor is always 365, including across leap years. Between 1 January 2024 and 1 January 2025 there are 366 days, so the exponent is 366/365, slightly more than one year. This is a convention, not an error. If your model needs actual/actual treatment, XNPV does not provide it.
A worked example
Set the discount rate to 10% in D1. Enter the dates as real Excel dates (not text) and the cash flows beside them:
| Row | A (date) | B (cash flow) | Days from first date |
|---|---|---|---|
| 2 | 2025-01-01 | -10000 | 0 |
| 3 | 2025-07-01 | 2500 | 181 |
| 4 | 2026-01-01 | 3000 | 365 |
| 5 | 2026-09-30 | 4000 | 637 |
| 6 | 2027-01-01 | 3500 | 730 |
The formula is:
=XNPV(D1, B2:B6, A2:A6)Each flow is discounted as follows:
- 2,500 / 1.1^(181/365) is about 2,384.6.
- 3,000 / 1.1^(365/365) is about 2,727.3.
- 4,000 / 1.1^(637/365) is about 3,387.1.
- 3,500 / 1.1^(730/365) is about 2,892.6.
The sum is about 11,391.5. Subtract the 10,000 outflow, which is undiscounted because it sits on the first date, and the XNPV is about 1,391.5. The project creates value at a 10% rate.
Verifying the result
You can reproduce XNPV in one cell with SUMPRODUCT. This is the independent check to build into every model:
=SUMPRODUCT(B2:B6 / (1 + D1)^((A2:A6 - A2) / 365))The two results should match to many decimal places. If they do not, suspect a date stored as text, a date that Excel truncated to a whole number, or a range that is misaligned between values and dates.
You can also check XNPV against NPV when the dates are exact year anniversaries in non-leap periods. For flows at 1 January 2025, 2026 and 2027:
=XNPV(D1, B2:B4, A2:A4)
=NPV(D1, B3:B4) + B2These agree because the day gaps are 365 and 730, which are exactly 1 and 2 years on the 365-day basis.
XNPV versus NPV on monthly flows
A common mistake is expecting XNPV on month-end dates to match NPV with a monthly rate. It will not, for two reasons:
- Months have 28 to 31 days, so the year fractions are not exact multiples of 1/12.
- An annual rate must be converted to an equivalent monthly rate before you use
NPV. The correct conversion is(1 + annual)^(1/12) - 1, notannual/12.
Both approaches are defensible. XNPV reflects the actual calendar, while NPV assumes equal periods. The difference is usually small but not zero. Choose one method for a model and document it.
What XNPV requires of its inputs
- Dates must be valid Excel dates. Text such as
"2025-01-01"that Excel has not converted produces#VALUE!. - Excel truncates dates to whole numbers, so any time-of-day part is ignored.
- No date may be earlier than the first date. Other dates can be in any order, but the first one is always the base.
valuesanddatesmust contain the same number of cells.- The cash flows need at least one positive and one negative value.
Common errors
| Symptom | Likely cause | Fix |
|---|---|---|
| `#VALUE!` | A date is text, blank in a non-empty position, or the rate is not numeric | Convert with `DATEVALUE`, retype the cell, or check the rate cell |
| `#NUM!` | A date precedes the first date, ranges differ in size, or all cash flows have the same sign | Sort so the earliest date is first, align the ranges, check signs |
| Result is much too high | The valuation date is not the first row, so a later flow is treated as t=0 | Put the valuation date and its cash flow (even if zero) in the first row |
| Result differs slightly from `NPV` | Day-count versus equal-period assumption | Expected. Use the same method everywhere in the model |
Design tips for models
Place a row for the valuation date even if the cash flow there is zero. This makes t=0 explicit. A zero first value still passes the XNPV sign requirement as long as later flows include both signs. If every other flow is positive, as in a bond, the valuation row needs a negative price or the function returns #NUM!.
A2: =ValuationDate B2: 0
A3: 2025-07-01 B3: -10000
A4: 2026-07-01 B4: 12000
=XNPV(D1, B2:B4, A2:A4)Here the investment on 1 July 2025 is discounted back to the valuation date in A2, which is the correct behavior when you value a project before it starts.
Exercise
Exercise
A project has these cash flows: -1,000 on 2025-01-01, +600 on 2026-01-01 and +600 on 2027-01-01. The annual discount rate is 10%. What does =XNPV(0.1, B2:B4, A2:A4) return, and how could you confirm it with a second formula?
Show answer
The day gaps are 365 and 730, so the exponents are exactly 1 and 2. PV = 600/1.1 + 600/1.21 = 545.45 + 495.87 = 1,041.32. Subtracting the undiscounted 1,000 gives an XNPV of about 41.32. Confirm it with =NPV(0.1, B3:B4) + B2, which gives the same value because the dates are exact non-leap year anniversaries, or with =SUMPRODUCT(B2:B4/(1+0.1)^((A2:A4-A2)/365)).