XIRR with non-contiguous entries for Flows (ranges) and Valuation (single period) based on cutoff date.

plshelpexcel

New Member
Joined
Aug 24, 2018
Messages
7
Office Version
  1. 365
Platform
  1. Windows
Hello All:

I am trying to find a way to calculate the XIRR for many investments over a vast Data Input structure that already exists and which is constantly being updated with new Inputs for the respective investments.

The challenge is to find a standard formula that produces XIRR calculations for such Data Input structure, which contains entries for Cashflows (ranges) and Valuations (a single and final value) that are mostly not contiguous. Furthermore, the Data Input structure also includes Cashflow entries for dates that go beyond the Valuation entries. There has to be a cutoff date for the XIRR calculations and such dates are equal to the single Valuation inputs.

Please refer to the attached example, which makes the problem easier to understand.

Each Investment has an individual column for Inputs that include Cashflow transactions (we would look at them over a range) and different period end Valuations (we would only consider one of these for each investment) The dates for the Investment Inputs are all entered into a single column that is shared by all Investments.

The Valuation value Inputs are found in the end of each Investment column after the Cashflows, and often are not in chronological order.

As stated before there is also a challenge because Cashflow entries beyond the last Valuation date often times exist in the Investment Input columns. This has to be accounted for when calculating the XIRR, as the calculation should ignore all entries that are more recent than the Valuation date Input.

Thank you very, very, very, very much for help and tips!!!!

XIRR.xlsx
BCDEFG
2Investment 1Investment 2Investment 3
3XIRR at cutoff:Desired XIRR:Desired XIRR:Desired XIRR:
410/31/202041.57%15.50%17.20%
512/31/202029.77%9.65%10.61%
69/30/202037.61%9.42%10.73%
72/28/202131.60%14.58%24.36%
8
9Valuation date:2/28/2021This Valuation date, or cutoff date, should serve for 1 and 2 below:
10XIRR0.00%-96.14%0.00%These current XIRR formulas do not work because they capture only the Cashflows. I cannot find a way to incorporate the single needed Valuation Input entry for each Investment into these XIRR formulas.
11
12Cashflows 1. Cashflows. The last Cashflow Input has to match the Valuation date. I need to capture a range of Flows while considering that data Input structure below includes Cashflows beyond the desired XIRR calculation date.
13Date2/28/20212/28/20212/28/2021
14Start ID156
15End ID161616
16
17Valuation2. Valuation date. Only one Valuation Input should be included in the XIRR calculation. The data Input structure includes several Valuation Inputs for different periods. Only one Valuation Input * controlled by cell D9 * should be used in the formula.
18Date2/28/20212/28/20212/28/2021
19Start ID156
20End ID202020
21
22
23Investment 1Investment 2Investment 3Data Input Structure: new entries are constantly added under each investment column that include Cash In and Cash Out inputs and also the Valuations inputs for multiple periods
24DateEntry Type$$$
251/1/2020Cash In(100.00)
261/8/2020Cash In(5.00)
271/14/2020Cash In(5.00)
281/22/2020Cash In(100.00)
292/7/2020Cash In(300.00)
302/14/2020Cash In(10.00)
312/20/2020Cash In(75.00)
322/28/2020Cash In(5.00)
333/17/2020Cash In(50.00)
343/24/2020Cash Out20.00
353/30/2020Cash Out70.00
364/7/2020Cash Out5.00
374/23/2020Cash Out5.00
381/5/2021Cash Out10.00
391/6/2021Cash Out10.00
402/7/2021Cash Out10.00
4110/31/2020Valuation315.19262.6684.05
4212/31/2020Valuation307.50256.2582.00
439/30/2020Valuation300.00250.0080.00
442/28/2021Valuation315.35262.7984.09
45
46B47:F136 CONTAIN XIRR CALCULATIONS WITH MANUAL TREATMENT OF DATA TO ACHIEVE REAL RESULTS
471/1/2020Cash In(100.00)
481/8/2020Cash In(5.00)
491/14/2020Cash In(5.00)
501/22/2020Cash In(100.00)
513/17/2020Cash In(50.00)
523/24/2020Cash Out20.00
5310/31/2020Valuation315.19
54XIRR41.57%
55
561/1/2020Cash In(100.00)
571/8/2020Cash In(5.00)
581/14/2020Cash In(5.00)
591/22/2020Cash In(100.00)
603/17/2020Cash In(50.00)
613/24/2020Cash Out20.00
6212/31/2020Valuation307.50
63XIRR29.77%
64
651/1/2020Cash In(100.00)
661/8/2020Cash In(5.00)
671/14/2020Cash In(5.00)
681/22/2020Cash In(100.00)
693/17/2020Cash In(50.00)
703/24/2020Cash Out20.00
719/30/2020Valuation300.00
72XIRR37.61%
73
741/1/2020Cash In(100.00)
751/8/2020Cash In(5.00)
761/14/2020Cash In(5.00)
771/22/2020Cash In(100.00)
783/17/2020Cash In(50.00)
793/24/2020Cash Out20.00
801/6/2021Cash Out10.00
812/28/2021Valuation315.35
82XIRR31.60%
83
842/7/2020Cash In(300.00)
852/28/2020Cash In(5.00)
863/30/2020Cash Out70.00
8710/31/2020Valuation262.66
88XIRR15.50%
89
902/7/2020Cash In(300.00)
912/28/2020Cash In(5.00)
923/30/2020Cash Out70.00
9312/31/2020Valuation256.25
94XIRR9.65%
95
962/7/2020Cash In(300.00)
972/28/2020Cash In(5.00)
983/30/2020Cash Out70.00
999/30/2020Valuation250.00
100XIRR9.42%
101
1022/7/2020Cash In(300.00)
1032/28/2020Cash In(5.00)
1043/30/2020Cash Out70.00
1051/5/2021Cash Out10.00
1062/28/2021Valuation262.79
107XIRR14.58%
108
1092/14/2020Cash In(10.00)
1102/20/2020Cash In(75.00)
1114/7/2020Cash Out5.00
1124/23/2020Cash Out5.00
11310/31/2020Valuation84.05
114XIRR17.20%
115
1162/14/2020Cash In(10.00)
1172/20/2020Cash In(75.00)
1184/7/2020Cash Out5.00
1194/23/2020Cash Out5.00
12012/31/2020Valuation82.00
121XIRR10.61%
122
1232/14/2020Cash In(10.00)
1242/20/2020Cash In(75.00)
1254/7/2020Cash Out5.00
1264/23/2020Cash Out5.00
1279/30/2020Valuation80.00
128XIRR10.73%
129
1302/14/2020Cash In(10.00)
1312/20/2020Cash In(75.00)
1324/7/2020Cash Out5.00
1334/23/2020Cash Out5.00
1342/7/2021Cash Out10.00
1352/28/2021Valuation84.09
136XIRR24.36%
Mr Excel ready
Cell Formulas
RangeFormula
D10:F10D10=+XIRR(INDEX(D25:D44,D14):INDEX(D25:D44,D15),INDEX($B$25:$B$44,D14):INDEX($B$25:$B$44,D15))
D13D13=D9
E13E13=D9
F13F13=D9
D14:F14D14=MATCH(TRUE,INDEX(D25:D44<>0,0),0)
D15:F15D15=MATCH(1,($C$25:$C$44<>$B$17)*($B$25:$B$44<=D$13),1)
D18,B74:D79,B65:D70,B56:D61D18=D9
E18E18=D9
F18F18=D9
D19:F19D19=MATCH(TRUE,INDEX(D25:D44<>0,0),0)
D20:F20D20=+MATCH(1,($C$25:$C$44=$B$17)*($B$25:$B$44=D$18),0)
B47:D50B47=B25
B51:D52B51=B33
B53:D53B53=B41
D54,D72,D63D54=XIRR(D47:D53,B47:B53)
B62:D62B62=B42
B71:D71B71=B43
B80:D80B80=B39
B81:D81B81=B44
D82D82=XIRR(D74:D81,B74:B81)
B84:C84,E84B84=B29
B85:C85,E85B85=B32
B86:C86,E93,B93:C93,E86B86=B35
B87:C87,E87B87=B41
E88,E100,E94E88=XIRR(E84:E87,B84:B87)
B90:C92,E102:E104,B102:C104,E96:E98,B96:C98,E90:E92B90=B84
B99:C99,E99B99=B43
B105:C105,E105B105=B38
B106:C106,E106B106=B44
E107E107=XIRR(E102:E106,B102:B106)
B109:C110,F109:F110B109=B30
B111:C112,F111:F112B111=B36
B113:C113,F113B113=B41
F114,F128,F121F114=XIRR(F109:F113,B109:B113)
B116:C119,F130:F133,B130:C133,F123:F126,B123:C126,F116:F119B116=B109
B120:C120,F120B120=B42
B127:C127,F127B127=B43
B134:C134,F134B134=B40
B135:C135,F135B135=B44
F136F136=XIRR(F130:F135,B130:B135)
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
The main problem you will have is an initial zero in the Dates column. That messes up the XIRR function (trailing zeroes are fine).

I took your first series and loaded the data in A1:C21, with the first row a header row.

In L2, I placed the valuation reference date option -- just got it out of the way of the data. It can be a dropdown/picklist. You choose the valuation date here and the data calculations should reference it.

In D2, I used the following formula and copied down to D21
IF(A2>$L$2,0,IF(A2=$L$2,C2,IF(B2="Valuation",0,C2)))

In L3, I entered the XIRR formula:
=XIRR(INDIRECT("D"&MATCH(TRUE,C2:C21<>0,0)+1&":D"&MATCH(9.9E+307,A:A)),INDIRECT("A"&MATCH(TRUE,C2:C21<>0,0)+1&":A"&MATCH(9.9E+307,A:A)))

This matched your results in my limited testing.

Key Idea:
You have to find the first non-zero data point and start from there.
=MATCH(TRUE,C2:C21<>0,0) will find it. Add 1 because you are starting in row 2.

The last data point can be found with MATCH(9.9E+307,A:A) (or MATCH(9.9E+307,C:C)). Note the missing optional third parameter. We don't want to find an exact match, just the last row.

This can be made fully dynamic, but this worked for me. You can play around with a guess for datasets with a lot of sign changes in the cashflows.
 
Upvote 0
Solution
The main problem you will have is an initial zero in the Dates column. That messes up the XIRR function (trailing zeroes are fine).

I took your first series and loaded the data in A1:C21, with the first row a header row.

In L2, I placed the valuation reference date option -- just got it out of the way of the data. It can be a dropdown/picklist. You choose the valuation date here and the data calculations should reference it.

In D2, I used the following formula and copied down to D21
IF(A2>$L$2,0,IF(A2=$L$2,C2,IF(B2="Valuation",0,C2)))

In L3, I entered the XIRR formula:
=XIRR(INDIRECT("D"&MATCH(TRUE,C2:C21<>0,0)+1&":D"&MATCH(9.9E+307,A:A)),INDIRECT("A"&MATCH(TRUE,C2:C21<>0,0)+1&":A"&MATCH(9.9E+307,A:A)))

This matched your results in my limited testing.

Key Idea:
You have to find the first non-zero data point and start from there.
=MATCH(TRUE,C2:C21<>0,0) will find it. Add 1 because you are starting in row 2.

The last data point can be found with MATCH(9.9E+307,A:A) (or MATCH(9.9E+307,C:C)). Note the missing optional third parameter. We don't want to find an exact match, just the last row.

This can be made fully dynamic, but this worked for me. You can play around with a guess for datasets with a lot of sign changes in the cashflows.
Thank you for the proposed solution!
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,177
Members
453,021
Latest member
Justyna P

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