For a stock portfolio with several purchases, use XIRR. It reads the date of every purchase, sale and final value. Excel’s IRR assumes the cash flows are evenly spaced. CAGR uses only a start value and an end value.
They agree when you invest once and hold for whole years. They split as soon as money goes in on uneven dates. The synthetic example below shows both cases, with the arithmetic and the spreadsheet formulas.
Synthetic example · USD · No fees or dividends
One stock, bought once or three times.
A fictional stock costs $100 on 4 January 2021 and $133.10 on 4 January 2024. In case 1, the investor buys once and waits. In case 2, the investor also buys after a dip and again about three months before the end.
| Date | Case 1 | Case 2 |
|---|---|---|
| Purchase | −$10,000100 shares at $100 | −$10,000100 shares at $100 |
| Purchase | No purchase | −$4,00050 shares at $80 |
| Purchase | No purchase | −$5,50050 shares at $110 |
| Final value | +$13,310100 shares at $133.10 | +$26,620200 shares at $133.10 |
| Formula | Case 1 | Case 2 |
|---|---|---|
| XIRRActual dates | 10% | 16.53% |
| IRROne row per period | 10% | 14.62% |
| CAGRFirst purchase to final value | 10% | 38.59% |
| CAGRTotal invested to final value | 10% | 10.93% |
All prices are invented, not market history. Rates are yearly and rounded to two decimals. In case 1, IRR gets one row per year. In case 2, it gets one row per cash flow. No sales, dividends, fees, taxes or currency changes are modeled.
01 / Read what each formula assumes
Each formula reads time in its own way.
IRR and XIRR find the rate at which the money you put in balances the money you get back. CAGR finds the steady yearly rate from a start value to an end value. With a single amount, that is the same rate. With more money coming in, each formula counts time differently.
- XIRR uses the real dates.
- You give it amounts and dates. Microsoft describes XIRR as the internal rate of return for cash flows that are not necessarily periodic. It discounts each flow by the days since the first date, on a 365-day year. The result is a yearly rate.
- IRR assumes equal periods.
- You give it amounts only. Microsoft says the cash flows must occur at regular intervals, such as monthly or annually, and that IRR reads them in order. The result is a rate per period: yearly for yearly rows, monthly for monthly rows.
- CAGR uses two values.
- You give it a start value, an end value and the number of years: (end value ÷ start value)1/years − 1. It cannot see money added or taken out in between. This is the formula the GIPS Handbook gives for turning a cumulative return into a yearly one. In Excel, the RRI function returns the same rate.
IRR and XIRR are money-weighted returns: the amounts and their timing both count. The money-weighted return definition shows this with an example you can change.
02 / One purchase, whole years
With one purchase held three years, all three give 10%.
Case 1 has one outflow and one final value, three years apart. The dates are 1,095 days apart, exactly 3 × 365, because no 29 February falls in between.
CAGR: (13,310 ÷ 10,000)1/3 − 1 = 10%
Check: 10,000 × 1.10 × 1.10 × 1.10 = 13,310
IRR has no dates, so it needs one row per period, even for periods with no money moving. Give it one row per year: −10,000, then 0, 0 and 13,310. It returns 10% a year. Type the zeros. Microsoft notes that IRR ignores empty cells. Without the zero rows, IRR would treat the 13,310 as arriving one period after the purchase and return 33.10%.
XIRR needs only the two dated flows. It turns the 1,095 days into 1,095 ÷ 365 = 3 years and returns 10% too.
XIRR: −10,000 + 13,310 ÷ (1 + r)1,095/365 = 0
r = 10%
03 / Three purchases, uneven dates
Add two purchases and the three figures split.
Case 2 adds $4,000 on 16 June 2022 and $5,500 on 2 October 2023. The gaps between the flows are 528, 473 and 94 days. The investor now holds 200 shares worth $26,620, for $19,500 invested.
| Purchase | Real time | IRR’s time |
|---|---|---|
| $10,000 | 1,095 days3 years | 3 periods |
| $4,000 | 567 days1.55 years | 2 periods |
| $5,500 | 94 days0.26 years | 1 period |
XIRR gives 16.53%. It finds the yearly rate at which each purchase, grown for its real time, adds up to the final value.
10,000 × (1 + r)1,095/365 + 4,000 × (1 + r)567/365 + 5,500 × (1 + r)94/365 = 26,620
r = 16.53%
Check it by growing each purchase at the more precise rate, 16.5343% a year. The $10,000 becomes about $15,826, the $4,000 about $5,073 and the $5,500 about $5,721. Together they make $26,620.
IRR gives 14.62%. Given the four amounts as four rows, it treats them as one period apart. Read as years, that assumes the last $5,500 was invested for a full year instead of 94 days. The same gain spread over more time looks like a lower rate.
10,000 × (1 + r)3 + 4,000 × (1 + r)2 + 5,500 × (1 + r) = 26,620
r = 14.62%
CAGR gives 38.59% or 10.93%, and neither fits. From the first purchase, it counts the $9,500 of new money as gain. From the total invested, it acts as if all $19,500 went in on the first day.
From the first purchase: (26,620 ÷ 10,000)1/3 − 1 = 38.59%
From the total invested: (26,620 ÷ 19,500)1/3 − 1 = 10.93%
Only XIRR uses both the amounts and their dates. That is why it is the figure to keep for this portfolio.
04 / Check the numbers yourself
Paste case 2 into a spreadsheet.
Put headers in row 1, the dates in A2 to A5 and the flows in B2 to B5. Enter real dates, such as =DATE(2021,1,4), not text. Enter -10000, -4000, -5500 and 26620: money you put in is negative, and the final value is positive.
| A — Date | B — Flow |
|---|---|
| Row 2 | −10,000 |
| Row 3 | −4,000 |
| Row 4 | −5,500 |
| Row 5 | +26,620 |
In order, these give the XIRR, the IRR, the CAGR from the first purchase and the CAGR from the total invested.
=XIRR(B2:B5,A2:A5) → 16.53%=IRR(B2:B5) → 14.62%=(B5/-B2)^ → 38.59%=(B5/-SUM(B2:B4))^ → 10.93%
IRR never reads column A. That is the whole difference with XIRR. For case 1, =IRR({-10000,0,0,13310}) returns 10% because the zero rows keep the periods one year apart. =RRI(3,10000,13310) returns the same 10% as the CAGR.
These are English Excel formulas. Your spreadsheet may use other function names or separators. Format the results as percentages. XIRR already returns a yearly rate, so do not annualize it again. If you run IRR on monthly rows, turn the monthly rate into a yearly one with (1 + monthly rate)12 − 1.
Without a spreadsheet, enter the four dated flows of case 2 in the free XIRR calculator. It counts days the same way and returns the same 16.53%.
05 / Choose the figure
Which one fits a stock portfolio?
- Use XIRR when money goes in or out on different dates. List each purchase as a negative amount and each sale or dividend you received as a positive amount, on its date. Then add the value of the shares you still hold as a positive amount on the end date. The partial-sale IRR example puts a sale in the same kind of list.
- Use IRR only on an even schedule. It fits flows that really happen once a month or once a year. Type a zero for every period with no flow, and convert a monthly rate to a yearly one before you compare it.
- Use CAGR for one amount left alone. A single purchase you still hold is the typical case. With any money added or taken out in between, CAGR mixes new money with gains.
XIRR is a money-weighted return, so it depends on when you added money. Two investors in the same stock can get different figures. To judge your choices against an ETF, give the ETF the same dated amounts and calculate its XIRR too. The repeated-purchase worksheet does this step by step.
A broker’s percentage can use another method, such as a time-weighted return, so it may not match your XIRR. Check the method and the dates before you compare. The TWR and MWR guide explains the difference.
XIRR always returns a yearly rate, even for a few weeks of history. A short period can then show an extreme figure. Keep the period return next to it, as the annualized vs cumulative return article explains. If XIRR returns an error, check that there is at least one negative and one positive amount and that no date comes before the first one. An error is not a zero return.
Sources and assumptions
- Microsoft — XIRR function: cash flows that are not necessarily periodic, real dates, discounting on a 365-day year and the error cases.
- Microsoft — IRR function: cash flows at regular intervals, read in order, with empty cells ignored.
- Microsoft — RRI function: an equivalent interest rate for the growth of an investment.
- CFA Institute — GIPS Standards Handbook for Firms, provision 2.A.29: what an IRR is, the formula (1 + r)1/n − 1 for annualizing a cumulative return and the leap-year effect of a 365-day year.
Sources checked 20 November 2026. The example is synthetic: invented prices on stated dates, in USD, with no fees, dividends, taxes, sales or currency changes. Rates are rounded to two decimals, and the calculations keep full precision. This is a method illustration, not a forecast or a recommendation. The GIPS reference explains a formula. It is not a claim of GIPS compliance.