Conditional XIRR with multiple columns for dates / cash flows

rotvik

New Member
Joined
Nov 5, 2019
Messages
2
I need a XIRR function that would only compute the XIRR for specific ISINs.
This is a picture of a sample file with unnecessary info deleted:



ISINDATE OF INVESTMENTDATE OF SALEBUY VOLUMESELL VOLUME
US747525103618.11. 20152421-385,86
US35461310183.12. 20154.11. 20191470,92-1021,68
US68268010367.12. 20154.5. 20161514,9-2736,58
US354613101811.12. 20154.11. 20191487,97-1582,69
US03783310057.1. 201631.7. 20191475,3-3370,39

<tbody>
</tbody>

For example a single line function:

<code style="margin: 0px; padding: 0px; border: 0px; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; vertical-align: baseline; box-sizing: inherit; white-space: inherit;">=XIRR(I33:J33;D31:E31)
</code>What I want would be the same function that can do it for non-contiguous ranges based on the ISIN condition. I.e. do XIRR which takes into account all dates in columns D:E and cash flows in columns I:J that are for the same ISIN.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Caveat: I use comma to separate parameters. You would use semicolons.

If we did it manually, we might array-enter (press ctrl+shift+enter instead of just Enter) the following formula:

=XIRR(IF($A$3:$A$6=A3, $I$3:$J$6,0), IF($A$3:$A$6=A3, $D$3:$E$6, 0))

Importantly, note that we start with row 3, which has the first cash flow that we are interested in (that is, for "US3546131018" in A3).

We would like to start with row 2, but Excel XIRR does not allow the first value/date pair to be zero.

So more generally, we must replace references to row 3 with references to the first row that we are interested in. That is what the following does (again, array-entered):

Code:
=XIRR(IF(INDEX($A$2:$A$6,MATCH(A3,$A$2:$A$6,0)):$A$6=A3, INDEX($I$2:$I$6,MATCH(A3,$A$2:$A$6,0)):$J$6, 0),
IF(INDEX($A$2:$A$6,MATCH(A3,$A$2:$A$6,0)):$A$6=A3, INDEX($D$2:$D$6,MATCH(A3,$A$2:$A$6,0)):$E$6, 0))

Obviously, it would be better to calculate MATCH(A3,$A$2:$A$6,0) one time in a helper cell.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,213,568
Messages
6,114,348
Members
448,570
Latest member
rik81h

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