XIRR Multiple Cashflows Ignoring Text Rows

tannaroo

New Member
Joined
Nov 15, 2022
Messages
13
Office Version
  1. 2019
Platform
  1. Windows
Hi
I'm trying to calculate the XIRR of various stock purchases/sales that have header rows with text. But XIRR doesn't like that so was tryinh to use the INDIRECT function within XIRR but I just couldn't figure it out. Any help would be greatly appreciated.

I want the XIRR function (cell A2) to basically ignore any row that has text, so it only identifies the dates (column A) with the corresponding cashflow (olumn F)


stock purchase example.xlsx
ABCDEF
2#VALUE!
3STOCK ATICKER ASECTOR
4DateBought/SoldNumberPriceAmount (Base)
510-Jun-22B10048.00(4,800.00)
613-Jun-22B10046.00(4,600.00)
714-Jun-22B10045.00(4,500.00)
814-Jul-22B5043.00(2,150.00)
931-Jul-22S(300)40.0012,000.00
1027-Sep-22B10043.00(4,300.00)
1117-Nov-2215060.009,000.00
12
13STOCK BTICKER BSECTOR
14DateBought/SoldNumberPriceAmount (Base)
1510-Jun-22B1,0006.00(6,000.00)
1613-Jun-22B1004.00(400.00)
1714-Jun-22B1003.00(300.00)
1814-Jul-22B509.00(450.00)
1917-Nov-221,25012.0015,000.00
Sheet1
Cell Formulas
RangeFormula
A2A2=XIRR(F5:F20, A5:A20)
A11,A19A11=TODAY()
C11C11=SUM(C5:C10)
F5:F10,F15:F18F5=ROUND(((-C5 * D5) + E5), 2)
F11,F19F11=-ROUND(((-C11 * D11) + E11), 2)
C19C19=SUM(C15:C18)
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
Try the following...

tannaroo.xlsm
ABCDEF
1
21.630387509
3STOCK ATICKER ASECTOR
4DateBought/SoldNumberPriceAmount (Base)
544722B10048-4800
644725B10046-4600
744726B10045-4500
844756B5043-2150
944773S-3004012000
1044831B10043-4300
1111/19/2022150609000
12
13STOCK BTICKER BSECTOR
14DateBought/SoldNumberPriceAmount (Base)
1544722B10006-6000
1644725B1004-400
1744726B1003-300
1844756B509-450
1911/19/202212501215000
Sheet1
Cell Formulas
RangeFormula
A2A2=XIRR(INDEX(F5:F19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),ROW(A5:A19)-ROW(A5)+{1,1}))))),INDEX(A5:A19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),ROW(A5:A19)-ROW(A5)+{1,1}))))))
A11,A19A11=TODAY()
C11C11=SUM(C5:C10)
F5:F10,F15:F18F5=ROUND(((-C5 * D5) + E5), 2)
F11,F19F11=-ROUND(((-C11 * D11) + E11), 2)
C19C19=SUM(C15:C18)


Hope this helps!
 
Upvote 0
For some reason the formula is not working for me. maybe i need an excel add-in of some type or my version of excel i snot supported?
 
Upvote 0
Hi all,

I got help previously with calculating XIRR on multiple rows. I wanted to take this one further to see if it was possible to calculate XIRR by start dates and end dates?

That is, I'd like to work out IRRs by year (Jan 1 to 31 Dec)

stock purchase example_2.xlsx
ABCDEF
231%
3STOCK ATICKER ASECTOR
4DateBought/SoldNumberPriceAmount (Base)
510-Jun-21B10048.00(4,800.00)
613-Jun-21B10046.00(4,600.00)
731-Dec-21B10045.00(4,500.00)
814-Jul-22B5043.00(2,150.00)
931-Jul-22S(300)40.0012,000.00
1031-Dec-22B10043.00(4,300.00)
1110-May-2315060.009,000.00
12
13STOCK BTICKER BSECTOR
14DateBought/SoldNumberPriceAmount (Base)
1510-Jun-22B1,0006.00(6,000.00)
1613-Jun-22B1004.00(400.00)
1731-Dec-22B1003.00(300.00)
1805-Feb-23B509.00(450.00)
1910-May-231,25012.0015,000.00
Sheet1
Cell Formulas
RangeFormula
A2A2=XIRR(INDEX(F5:F19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),ROW(A5:A19)-ROW(A5)+{1,1}))))),INDEX(A5:A19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),ROW(A5:A19)-ROW(A5)+{1,1}))))))
A11,A19A11=TODAY()
C11C11=SUM(C5:C10)
F15:F18,F5:F10F5=ROUND(((-C5 * D5) + E5), 2)
F11,F19F11=-ROUND(((-C11 * D11) + E11), 2)
C19C19=SUM(C15:C18)
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
First of all, I see that I previously missed the fact that your date column contains today's date with the current stock value. As such, my formula incorrectly includes it in the calculation. Now, while the formula can be amended to exclude rows containing today's date, I would suggest that you instead return the date as a text value so that it doesn't get included in the calculation. Or, better still, have it labelled "As of 5/10/2023". This way the value is a text value, and it's clear that it's not going to be part of the calculation. Here's an example...

tannaroo v2.xlsm
ABCDEF
1
22.98023E-09
3STOCK ATICKER ASECTOR
4DateBought/SoldNumberPriceAmount (Base)
56/10/2021B10048($4,800.00)
66/13/2021B10046($4,600.00)
712/31/2021B10045($4,500.00)
87/14/2022B5043($2,150.00)
97/31/2022S-30040$12,000.00
1012/31/2022B10043($4,300.00)
11As of 5/10/202315060$9,000.00
12
13STOCK BTICKER BSECTOR
14DateBought/SoldNumberPriceAmount (Base)
156/10/2022B1,0006($6,000.00)
166/13/2022B1004($400.00)
1712/31/2022B1003($300.00)
182/5/2023B509($450.00)
19As of 5/10/20231,25012$15,000.00
Sheet1
Cell Formulas
RangeFormula
A2A2=XIRR(INDEX(F5:F19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),ROW(A5:A19)-ROW(A5)+{1,1}))))),INDEX(A5:A19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),ROW(A5:A19)-ROW(A5)+{1,1}))))))
A11,A19A11="As of "&TEXT(TODAY(),"m/d/yyyy")
C11C11=SUM(C5:C10)
F5:F10,F15:F18F5=ROUND(((-C5 * D5) + E5), 2)
F11,F19F11=-ROUND(((-C11 * D11) + E11), 2)
C19C19=SUM(C15:C18)


Then, to amend the formula so that it takes into consideration a start date and end date, try...

tannaroo v2.xlsm
ABCDEF
1
2#NUM!1/1/202212/31/2022
3STOCK ATICKER ASECTOR
4DateBought/SoldNumberPriceAmount (Base)
56/10/2021B10048($4,800.00)
66/13/2021B10046($4,600.00)
712/31/2021B10045($4,500.00)
87/14/2022B5043($2,150.00)
97/31/2022S-30040$12,000.00
1012/31/2022B10043($4,300.00)
11As of 5/10/202315060$9,000.00
12
13STOCK BTICKER BSECTOR
14DateBought/SoldNumberPriceAmount (Base)
156/10/2022B1,0006($6,000.00)
166/13/2022B1004($400.00)
1712/31/2022B1003($300.00)
182/5/2023B509($450.00)
19As of 5/10/20231,25012$15,000.00
Sheet2
Cell Formulas
RangeFormula
A2A2=XIRR(INDEX(F5:F19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),IF(A5:A19>=B2,IF(A5:A19<=C2,ROW(A5:A19)-ROW(A5)+{1,1}))))))),INDEX(A5:A19,N(IF(1,MODE.MULT(IF(ISNUMBER(A5:A19),IF(A5:A19>=B2,IF(A5:A19<=C2,ROW(A5:A19)-ROW(A5)+{1,1}))))))))
A11,A19A11="As of "&TEXT(TODAY(),"m/d/yyyy")
C11C11=SUM(C5:C10)
F5:F10,F15:F18F5=ROUND(((-C5 * D5) + E5), 2)
F11,F19F11=-ROUND(((-C11 * D11) + E11), 2)
C19C19=SUM(C15:C18)
Press CTRL+SHIFT+ENTER to enter array formulas.


I'm assuming that since there's at least one positive and one negative value, the reason it returns #NUM! is that it's unable to find a result that works after 'X' number of tries. But I'll leave it for you to sort out. ;)

Hope this helps!
 
Upvote 0
Thank you very much Domenic - that is awesome!

Regarding your comment about amending your initial formula to 'text out today's date', unless I am missing something with the XIRR function, I want todays date with the current market price included in the XIRR function. I'm trying to measure the market-to-market value with the current XIRR, notwithstanding it may provide some high/loss numbers as its not annualised.

Was there a specific reason why you were thinking it should excluded?
 
Upvote 0
Oh I see, so you actually want it included in the calculation. I thought since it's not actually a cash flow, it shouldn't be included. I'm not a statistician, so I could be wrong.

But then when the calculation takes into consideration a start date and an end date, such as 1/1/2022 and 12/31/2022, today's current stock value won't be included.

So I'm a bit confused. :)
 
Upvote 0
Oh I see, so you actually want it included in the calculation. I thought since it's not actually a cash flow, it shouldn't be included. I'm not a statistician, so I could be wrong.

But then when the calculation takes into consideration a start date and an end date, such as 1/1/2022 and 12/31/2022, today's current stock value won't be included.

So I'm a bit confused. :)

You are correct - its not a cashflow item per se but I treat as a 'liquidation' value. I'm amending the formula to suit my needs but your help has been immensely appreciated.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,333
Members
452,636
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top