Home › Templates › XIRR spreadsheet
XIRR Spreadsheet
A free XIRR spreadsheet for Excel and Google Sheets. Log every deposit and withdrawal for up to five accounts, add each account's current value, and it returns your personal rate of return (the money-weighted return) with XIRR, checks the answer two independent ways, and puts it next to the simple return, CAGR and the time-weighted return.
Use it in Google Sheets: choose File → Import → Upload in Sheets and pick the .xlsx, or upload it to Google Drive and open it with Google Sheets. Google Sheets has its own XIRR function with the same arguments and default guess (see below).
| Account | Deposits | Withdrawals | Ending value | Simple return | Day-1 CAGR | XIRR | Dietz check | NPV check |
|---|---|---|---|---|---|---|---|---|
| Brokerage (example) | $62,000 | $3,000 | $69,862 | 17.5% | 3.46% | 5.86% | 5.66% | Pass |
| Retirement account (example) | $25,000 | $0 | $31,480 | 25.9% | 5.00% | 8.55% | 8.16% | Pass |
| Crypto (example) | $7,500 | $4,000 | $5,260 | 23.5% | 4.70% | 8.21% | 8.20% | Pass |
| All accounts | $94,500 | $7,000 | $106,602 | 20.2% | 3.96% | 6.76% | 6.52% | Pass |
XIRR (per year)CAGR as if every deposit were made on day 1Simple return (whole period, not per year)
What's inside the spreadsheet
| Tab | What you type | What it calculates |
|---|---|---|
| Start here | Nothing | Steps, sign convention, the formulas in plain words, colour key, limits, disclaimer |
| Summary | Up to 5 account names, each account's ending value and its valuation date | Status per account; deposits and withdrawals (SUMIFS); net invested; gain; simple return; first cash flow date and days held; CAGR as if every deposit were made on day 1; XIRR; NPV at the XIRR rate and a Modified Dietz estimate as cross-checks; the same for all accounts together; a native column chart |
| Cash flows | Date, account (dropdown), Deposit or Withdrawal, amount as a positive number, optional note. 2,500 rows, any order | A row check, the signed flow XIRR needs, and helper columns that give each account its own XIRR range |
| TWR | One row per cash flow: date, account value just before it, the flow; then the final value. Up to 500 rows | Sub-period returns, chain-linked time-weighted return (cumulative, and per year when the period is a year or more), XIRR on the same rows, the gap between them, a bar chart |
| Example summary, Example cash flows, Example TWR | Already filled with fictional data (change any yellow cell) | The same calculations, so you can see a full result before entering your own |
How to use it
- On Summary, type a name for each account in column A, for example "Brokerage" or "IRA". The names feed the Account dropdown.
- On Cash flows, add one row for every time you moved money in or out: date, account, Deposit or Withdrawal, and the amount as a positive number. Order does not matter. Leave out dividends and interest that stayed in the account: they are part of the return, not cash flows.
- Back on Summary, enter each account's current value and the date of that value, such as the last statement date.
- Check that Status says OK and the cross-check says Pass. Read XIRR in column M. The "Rows to check" counter must be 0; any incomplete row on Cash flows shows a red "Check this row".
- Optional: to see how much of the result came from your timing, fill the TWR tab with the account value just before each deposit or withdrawal. It shows the time-weighted return next to XIRR for the same account.
Sign convention
XIRR looks at cash flows from your side of the account. The sheet applies the signs, so you never type a minus sign.
| What happened | You type | XIRR sees |
|---|---|---|
| You put money in (a contribution, a transfer in, a purchase paid from your bank) | Deposit, 1,000 | −1,000 |
| You took money out (a transfer to your bank, a cash withdrawal) | Withdrawal, 400 | +400 |
| What the account is worth on the valuation date | Summary: ending value 5,000 | +5,000 |
| Dividends or interest reinvested in the account | Nothing | — |
Google's help page uses the same rule: each amount "should be positive if it represents income from the perspective of the owner of the investment (e.g. coupons) or negative if it represents payments" (Google Docs Editors Help, XIRR).
The formulas, explained
XIRR
Microsoft defines XIRR as the rate that makes XNPV zero: "The rate of return calculated by XIRR is the interest rate corresponding to XNPV = 0" (Microsoft Support, XIRR function). XNPV discounts each payment on a 365-day year from the first date (Microsoft Support, XNPV function). Written out, XIRR is the r that solves:
0 = Σ Pi ÷ (1 + r)(di − d1) ÷ 365where Pi is each cash flow, di its date and d1 the first date. Excel finds r by trial: it starts at the guess (10% if you leave it out) and stops when the result is "accurate within 0.000001 percent", or returns #NUM! "after 100 tries".
Why there is a helper row, and why it does not change the answer
Microsoft notes: "If any number in dates precedes the starting date, XIRR returns the #NUM! error value." A log with several accounts in any order would break that rule. So each account gets its own helper column in which every other row is $0, and every $0 row and the first helper row are dated at the earliest date in the log. A $0 flow adds nothing to the sum, and moving the start date only multiplies every term by the same factor, so the rate that makes the sum zero stays the same. The test in this page's sources solved Microsoft's own five-payment example through this layout and got 0.373362534; Microsoft shows 0.373362535 (37.34%), a difference only in the ninth decimal place.
Two cross-checks
NPV at the XIRR rate. SUMPRODUCT discounts every flow at the XIRR result on Actual/365 days. If XIRR found a true root, the total is $0 and the sheet says Pass. Any other number means the XIRR result should not be trusted. Modified Dietz. A separate, approximate formula: gain ÷ deposits weighted by the share of the period each was invested, then annualized. It does not use XIRR at all, so a large gap between the two is a sign to look at the data. It is close to XIRR when deposits are small compared with the balance, and drifts when they are large.
Simple return and CAGR
Simple return = (ending value + withdrawals − deposits) ÷ deposits. It ignores time. The CAGR column uses the familiar ((end ÷ start)1 ÷ years − 1) with all deposits as the start value on the first date. That is how a single-start CAGR treats a savings plan, and it understates the return whenever money went in later. Compare with the CAGR calculator for one lump sum.
Time-weighted return
Value the account just before each external cash flow. Each sub-period return is the value before a flow ÷ the value after the previous flow − 1. Chain-linking multiplies (1 + each sub-period return) and subtracts 1. This is the "geometrically link periodic and sub-period returns" step the 2020 GIPS standards for firms require for time-weighted returns (provision 2.A.24). Following provision 2.A.12, "Returns for periods of less than one year must not be annualized", the TWR tab shows only the cumulative figure under a year.
Exact formulas from the blank tabs (row 5 or 6 on Summary and Cash flows, row 7 on TWR). In the file most are wrapped in IF(D5="OK", …, "") or IF($L$6="OK", …, "") so nothing shows until the inputs are valid. Functions used: XIRR, SUMIFS, COUNTIFS, SUMPRODUCT, MAX, MIN, SUM, COUNT, COUNTA, COUNTIF, INDEX, MATCH, IF, IFERROR, AND, OR, NOT, ISNUMBER, N, ROUND, DATE.
| Field | Formula |
|---|---|
| Signed flow, all accounts (Cash flows G6) | =IF(AND(ISNUMBER(A6),ISNUMBER(D6),N(D6)>0,ISNUMBER(MATCH(B6,Summary!$A$5:$A$9,0))),IF(C6="Deposit",-D6,IF(C6="Withdrawal",D6,0)),0) |
| XIRR start date, helper row (Cash flows H5) | =IF(COUNT($A$6:$A$2505)=0,DATE(2000,1,1),MIN($A$6:$A$2505)) |
| XIRR date for each row (Cash flows H6) | =IF(G6<>0,A6,$H$5) |
| Account 1 flow (Cash flows I6) | =IF(B6=Summary!$A$5,G6,0) |
| Deposits per account (Summary E5) | =IF(A5="","",SUMIFS('Cash flows'!$D$6:$D$2505,'Cash flows'!$B$6:$B$2505,A5,'Cash flows'!$C$6:$C$2505,"Deposit",'Cash flows'!$A$6:$A$2505,">0")) |
| Simple return (Summary I5) | =H5/E5 |
| CAGR as if all deposits were on day 1 (Summary L5) | =IF(K5>=365,((B5+F5)/E5)^(365/K5)-1,"Under 1 year") |
| XIRR (Summary M5) | =IFERROR(XIRR('Cash flows'!$I$5:$I$2510,'Cash flows'!$H$5:$H$2510,MAX(-0.9,MIN(5,IFERROR(O5+0,0.1)))),IFERROR(XIRR('Cash flows'!$I$5:$I$2510,'Cash flows'!$H$5:$H$2510),"No solution")) |
| Cross-check 1: NPV at the XIRR rate (Summary N5) | =IF(ISNUMBER(M5),ROUND(SUMPRODUCT('Cash flows'!$I$5:$I$2510,(1+M5)^(-('Cash flows'!$H$5:$H$2510-'Cash flows'!$H$5)/365)),4),"") |
| Cross-check 2: Modified Dietz, annualized (Summary O5) | =IF(AND(D5="OK",N(R5)>0),(1+(B5-G5)/R5)^(365/K5)-1,"") |
| Sub-period return (TWR E7) | =IF(AND(ISNUMBER(A7),ISNUMBER(B7),ISNUMBER(D6)),IF(D6>0,B7/D6-1,""),"") |
| Chain-linked TWR (TWR F7) | =IF(AND(ISNUMBER(E7),ISNUMBER(F6)),(1+F6)*(1+E7)-1,"") |
| TWR per year (TWR L13) | =IF($L$10>=365,(1+$L$12)^(365/$L$10)-1,"Under 1 year: not annualized") |
Worked example from the sample data
The Example tabs follow a fictional investor with three accounts from 3 Jan 2022 to 30 Sep 2026. The Brokerage account had these cash flows:
| Date | Type | Amount typed | XIRR sees |
|---|---|---|---|
| 3 Jan 2022 | Deposit | $10,000 | −$10,000 |
| 15 Jun 2022 | Deposit | $5,000 | −$5,000 |
| 3 Jan 2023 | Deposit | $5,000 | −$5,000 |
| 5 Jul 2023 | Withdrawal | $3,000 | $3,000 |
| 2 Jan 2024 | Deposit | $25,000 | −$25,000 |
| 1 Jul 2024 | Deposit | $5,000 | −$5,000 |
| 2 Jan 2025 | Deposit | $5,000 | −$5,000 |
| 1 Jul 2025 | Deposit | $2,000 | −$2,000 |
| 2 Jan 2026 | Deposit | $5,000 | −$5,000 |
| 30 Sep 2026 | Ending value | $69,862.24 | $69,862.24 |
- Totals: $62,000 deposited, $3,000 withdrawn, ending value $69,862.24. Gain = $69,862.24 + $3,000 − $62,000 = $10,862.24, a simple return of 17.52%.
- CAGR as if all deposits were on day 1: (($69,862.24 + $3,000) ÷ $62,000)365 ÷ 1,731 − 1 = 3.46% a year. Too low, because most of the money went in later.
- XIRR: 5.86% a year. Discounting every row of the table at that rate sums to $0 (cross-check Pass). Modified Dietz gives 5.66%, close behind.
- Other accounts: the retirement account (five yearly deposits of $5,000) has an XIRR of 8.55%; the crypto account, with a $4,000 withdrawal in the middle, 8.21%. All three together: 6.76%.
The same account, time-weighted
The Example TWR tab holds the Brokerage account's (fictional) statement values just before each flow:
| Date | Value before the flow | Flow | Value after | Sub-period return | Cumulative TWR |
|---|---|---|---|---|---|
| 3 Jan 2022 | $0.00 | $10,000 | $10,000.00 | — | 0.00% |
| 15 Jun 2022 | $8,500.00 | $5,000 | $13,500.00 | −15.00% | −15.00% |
| 3 Jan 2023 | $13,230.00 | $5,000 | $18,230.00 | −2.00% | −16.70% |
| 5 Jul 2023 | $20,417.60 | −$3,000 | $17,417.60 | 12.00% | −6.70% |
| 2 Jan 2024 | $18,811.01 | $25,000 | $43,811.01 | 8.00% | 0.76% |
| 1 Jul 2024 | $38,553.69 | $5,000 | $43,553.69 | −12.00% | −11.33% |
| 2 Jan 2025 | $45,295.84 | $5,000 | $50,295.84 | 4.00% | −7.78% |
| 1 Jul 2025 | $53,313.59 | $2,000 | $55,313.59 | 6.00% | −2.25% |
| 2 Jan 2026 | $60,291.81 | $5,000 | $65,291.81 | 9.00% | 6.55% |
| 30 Sep 2026 | $69,862.24 | — | $69,862.24 | 7.00% | 14.00% |
Chain-linking the nine sub-period returns gives 14.00% over 1,731 days, or 2.80% a year. XIRR on the same rows is 5.86%, identical to the Summary tab. TWR minus XIRR is −3.06 pp: XIRR is higher because the first two losses (−15% and −2%) hit balances of only $10,000 and $13,500, while the last four gains (+4%, +6%, +9%, +7%) landed on $43,554 to $65,292. The −12% half-year right after the $25,000 deposit hurt, but less than the later gains helped. The investments did 2.80% a year; the investor earned 5.86% a year on their money, mostly thanks to when the money went in.
Time-weighted vs money-weighted return: why they differ
The GIPS standards define the two this way (GIPS for Firms, 2020 edition, glossary):
Money-weighted return: "The return for a period that reflects the change in value and the timing and size of external cash flows."
Time-weighted return: "A method of calculating period-by-period returns that reflects the change in value and negates the effects of external cash flows."
An external cash flow is "Capital (cash or investments) that enters or exits a portfolio", and "Dividend and interest income payments are not considered external cash flows." So when you add money right before a fall, the money-weighted return suffers and the time-weighted return does not. A fictional example where they split badly:
| Date | Value before the deposit | Deposit | Value after | Return since last row |
|---|---|---|---|---|
| 1 Jan 2024 | $0 | $10,000 | $10,000 | — |
| 1 Jan 2025 | $15,000 | $90,000 | $105,000 | 50% |
| 1 Jan 2026 | $84,000 | — | $84,000 | −20% |
- Time-weighted: (1 + 50%) × (1 − 20%) − 1 = 20% over two years, 9.53% a year. The investments gained.
- Money-weighted (XIRR): deposits of $10,000 and $90,000, worth $84,000 at the end: −14.74% a year. The investor lost $16,000.
Both are correct; they answer different questions. Use XIRR to judge your own result, including your timing. Use time-weighted return to judge a fund, a manager or a strategy against a benchmark, because the manager does not control when you add or take money. That is why GIPS says a firm "must present time-weighted returns unless certain criteria are met" (provision 1.A.35), the criteria being control over external cash flows plus features such as a closed-end or fixed-life fund. Paste the three rows above into the TWR tab to reproduce both numbers.
Common mistakes
- Logging dividends as deposits. Reinvested dividends and interest are already in the account value. Logging them again double-counts money you never added.
- Forgetting the ending value. Without it, XIRR only sees money going in. The sheet will not show a result until the ending value and its date are entered.
- Valuing on a different date than the last flow. A deposit dated after the valuation date is flagged: "A cash flow is after the valuation date".
- Reading XIRR for a few months of history. XIRR is always per year. Two weeks of a 2% gain annualizes to a very large number. Under a year, read the simple return as well.
- Comparing your XIRR with a fund's published return. Fund returns are time-weighted. Use the TWR tab to compare like with like.
- Mixing transfers between your own accounts. Moving $5,000 from one tracked account to another is a withdrawal from one and a deposit to the other; for the All accounts row the two cancel out.
XIRR error messages
| Error | Cause (Microsoft) | What the template does |
|---|---|---|
| #NUM! | "at least one positive cash flow and one negative cash flow" missing | Status says "No deposits logged" or asks for the ending value |
| #NUM! | "any number in dates precedes the starting date" | Helper row at the earliest date; the log can be in any order |
| #NUM! | "values and dates contain a different number of values" | Ranges are fixed and equal in length |
| #NUM! | "can't find a result that works after 100 tries" | Uses the Modified Dietz estimate as the guess, then the default; else shows "No solution" |
| #VALUE! | "any number in dates is not a valid date" | Date validation on input cells; rows without a valid date are skipped and flagged |
Limits
- XIRR can have no answer, or more than one, when money moves in and out several times. The NPV check proves a result is a valid root but cannot tell you whether another root exists.
- Up to 5 accounts and 2,500 cash flow rows on the Cash flows tab (500 per account on average); up to 500 valuation rows on the TWR tab.
- The TWR tab needs the account value on every cash flow date. Monthly statement values with flows between them give an approximation.
- Returns are before tax unless you enter after-tax values. Fees charged inside the account are already in the value.
- The All accounts row treats each ending value as a sale on its own valuation date; use the same date for every account.
- Recalculation was tested in LibreOffice. The functions used exist in Excel 2016+ and Google Sheets; the file was not opened in those programs for this check.
FAQ
What is XIRR in Excel?
XIRR is Excel's function for the internal rate of return of cash flows that happen on irregular dates. Microsoft describes it as returning "the internal rate of return for a schedule of cash flows that is not necessarily periodic". For an investor, it is the yearly rate that makes every deposit, withdrawal and the current value net to zero, which is the money-weighted return on your own money.
How do I calculate my personal rate of return in a spreadsheet?
List every deposit as a negative amount and every withdrawal as a positive amount, each with its date. Add today's account value as a final positive amount dated today. Then use =XIRR(amounts, dates). This template does the signs for you: you type positive amounts and pick Deposit or Withdrawal, and it runs XIRR per account and for all accounts together.
Why is my XIRR different from CAGR?
CAGR uses a start value and an end value only, so it assumes all the money was there from day one. If you added money over time, much of it was invested for less time, and CAGR understates the return. In the fictional example the Brokerage account's CAGR computed that way is 3.46%, while XIRR, which credits each deposit only from its own date, is 5.86%.
What is the difference between time-weighted and money-weighted return?
The GIPS standards define a money-weighted return as one that "reflects the change in value and the timing and size of external cash flows", and a time-weighted return as one that "negates the effects of external cash flows". XIRR is money-weighted: it measures your result, including when you added or took out money. Time-weighted return measures the investments alone, which is why fund and manager track records use it.
Why does XIRR return #NUM!?
Microsoft lists the causes: there is no negative or no positive cash flow, a date comes before the first date in the range, the two ranges have a different number of values, or XIRR cannot find a result after 100 tries. A non-date in the dates range returns #VALUE!. This template avoids the first three by design and tries a second starting guess before it reports 'No solution'.
Does XIRR work in Google Sheets?
Yes. Google Sheets has XIRR(cashflow_amounts, cashflow_dates, [rate_guess]) with the same 0.1 default guess, and says the amounts "must contain at least one negative and one positive cash flow". To use this template there, choose File → Import → Upload and pick the .xlsx, or open it from Google Drive. No macros or add-ons.
Related tools and templates
- CAGR calculatorGrowth rate between two values
- ROI calculatorReturn on a single investment
- Investment trackerHoldings, cost basis and value
- Stock portfolio trackerPositions, gains and allocation
- Dividend trackerIncome by holding and month
- DCA calculatorRegular investing over time
- Compound interest spreadsheetHow a balance grows
- All templatesFree spreadsheets
Educational template only, not investment or tax advice. Example data is fictional: the investor, accounts, dates, amounts and returns are made up to show the formulas and are not a recommendation, a forecast or a typical result. Past returns do not predict future returns. Function behaviour is quoted from Microsoft Support and Google Docs Editors Help, and definitions from the 2020 GIPS standards for firms (CFA Institute), all retrieved on 6 November 2026.