Calculate running XIRR for specific account

kapvg

New Member
Joined
Jun 30, 2018
Messages
25
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi,

Need help with the below issue.
I have a dataset with multiple investment accounts for which I want to calculate the XIRR on a recurring/ongoing basis. Sample data for 2 accounts below

Account 1
Book1
BCDEFGHI
2AccountDateParticularsEmployee Contribution ($)Employer's Contribution ($)Total ($)Total Fund ValueXIRR
3Account-1XY18-Jan-2018By Contribution$840.40$0.00$840.40 
4Account-1XY31-Mar-2018Closing Balance$804.16-20.02%
5Account-1XY3-Apr-2018By Contribution$5,976.40$0.00$5,976.40 
6Account-1XY29-Jun-2018Closing Balance$6,862.692.58%
7Account-1XY28-Sep-2018Closing Balance$6,944.003.67%
8Account-1XY31-Dec-2018Closing Balance$7,023.853.96%
9Account-1XY31-Mar-2019Closing Balance$7,341.507.56%
10Account-1XY28-Jun-2019Closing Balance$7,392.996.65%
11Account-1XY30-Sep-2019Closing Balance$7,288.554.50%
12Account-1XY31-Dec-2019Closing Balance$7,610.966.42%
13Account-1XY24-Feb-2020By Contribution$4,976.40$0.00$4,976.40 
14Account-1XY18-Mar-2020By Voluntary Contributions$25,000.00$0.00$25,000.00 
15Account-1XY31-Mar-2020Closing Balance$35,550.37-8.51%
16Account-1XY30-Jun-2020Closing Balance$40,585.8814.94%
17Account-1XY30-Sep-2020Closing Balance$43,211.2018.12%
18Account-1XY31-Dec-2020Closing Balance$51,260.7630.33%
19Account-1XY23-Mar-2021By Voluntary Contributions$1,500.00$0.00$1,500.00 
20Account-1XY31-Mar-2021Closing Balance$54,652.7527.95%
sample data
Cell Formulas
RangeFormula
I3:I20I3=IFERROR(XIRR(IF(ROW($C$3:C3)=ROW(C3), -1*($H$3:H3))+$G$3:G3, $C$3:C3),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


Account 2
Book1
KLMNOPQR
2AccountDateParticularsEmployee Contribution ($)Employer's Contribution ($)Total ($)Total Fund ValueXIRR
3Account-2AB18-Jan-2018Tier-2 Contribution$2,076.40$0.00$2,076.40 
4Account-2AB31-Mar-2018Closing Balance$1,970.11-23.39%
5Account-2AB3-Apr-2018Tier-2 Contribution$4,976.40$0.00$4,976.40 
6Account-2AB29-Jun-2018Closing Balance$6,926.56-5.87%
7Account-2AB28-Sep-2018Closing Balance$7,085.450.85%
8Account-2AB31-Dec-2018Closing Balance$7,172.042.10%
9Account-2AB31-Mar-2019Closing Balance$7,579.577.08%
10Account-2AB28-Jun-2019Closing Balance$7,765.437.71%
11Account-2AB30-Sep-2019Closing Balance$7,751.816.27%
12Account-2AB31-Dec-2019Closing Balance$8,066.277.72%
13Account-2AB24-Feb-2020Tier-2 Contribution$4,976.40$0.00$4,976.40 
14Account-2AB31-Mar-2020Closing Balance$10,336.73-12.01%
15Account-2AB30-Jun-2020Closing Balance$11,917.06-0.63%
16Account-2AB30-Sep-2020Closing Balance$12,680.753.04%
17Account-2AB31-Dec-2020Closing Balance$14,861.6210.88%
18Account-2AB23-Mar-2021Tier-2 Contribution$1,500.00$0.00$1,500.00 
19Account-2AB31-Mar-2021Closing Balance$17,054.7711.83%
sample data
Cell Formulas
RangeFormula
R3:R19R3=IFERROR(XIRR(IF(ROW($L$3:L3)=ROW(L3), -1*($Q$3:Q3))+$P$3:P3, $L$3:L3),"")
Press CTRL+SHIFT+ENTER to enter array formulas.


The XIRR formula used is based on help from XIRR function with 1 value from another cell and it works perfectly when used for a single account.

Without using VBA, I want to combine all the accounts into a single table that can be filtered/sorted as per the user's choice and I am wondering if the XIRR formula can be modified so as to return the correct XIRR for a specific account (i.e. Account1 or Account2) even when used in the combined dataset.
I saw the post: Calculate XIRR for a specific "item" from a table that's sorted by date but given my limited expertise I am unable to utilize/modify that formula for the above scenario :(

Any help would be greatly appreciated.

~kg
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
The XIRR formula used is based on help from XIRR function with 1 value from another cell and it works perfectly when used for a single account.

Looking back, I see that I over-complicated the formula. For your purposes, the following simplified formula can be array-entered:

=IF(H3="", "", XIRR(IF(ROW($C$3:C3)=ROW(C3), -H3)+$G$3:G3, $C$3:C3))

The point is: since ROW($C$3:C3)=ROW(C3) is true only for the last row of the term $C$3:C3, on the last row of the term $H$3:H3 is used, namely H3.

-----

I want to combine all the accounts into a single table that can be filtered/sorted as per the user's choice and I am wondering if the XIRR formula can be modified so as to return the correct XIRR for a specific account (i.e. Account1 or Account2) even when used in the combined dataset. I saw the post: Calculate XIRR for a specific "item" from a table that's sorted by date

First, are you interested in a solution based on DRSteele's suggestion in the cited earlier thread, or based on my suggestion?

-----

Second, when you say ``I want to combine [...] into a single table``, do you mean that you will __manually__ combine all data into a single table?

Or do you mean that you want the __formula__ to treat your separate tables as one combined table automagically?(!)

BTW, it is not necessary for the data to be sorted, except that for each account, in would be convenient if the first transaction appears before all of the other transactions for that account.

The XIRR function does not require data to be ordered by date, except that the first date is treated as the "present value" date. It must be earliest cash flow.

-----

Finally, please provide an example of the combined tables, __and__ how you will provide "a specific account", __and__ what you mean by "the" correct XIRR.

In the example in the cited earlier thread, the "specific account" was in a cell that is separate from the data table, and I relied on a parallel helper cell to simplify the XIRR formula.

Moreover, only one XIRR is calculated for each "specific account", namely the XIRR for all cash flows related to the "specific account".

In contrast, in your original examples, you are calculating a "running" XIRR for __each__ closing balance, on an "ongoing basis", as you write. That is, it is not "the" single correct XIRR; instead, it is __multiple__ XIRRs for each account.

Also, would all the data for each account be together in the combined table, effectively concatenating each separate table?

Or would cash flows for different accounts be interleaved, perhaps ordered by date, not by account?
 
Upvote 0
Looking back, I see that I over-complicated the formula. For your purposes, the following simplified formula can be array-entered:

=IF(H3="", "", XIRR(IF(ROW($C$3:C3)=ROW(C3), -H3)+$G$3:G3, $C$3:C3))

The point is: since ROW($C$3:C3)=ROW(C3) is true only for the last row of the term $C$3:C3, on the last row of the term $H$3:H3 is used, namely H3.

-----

Thanks @joeu2004 . The above makes sense and I believe it will help speed up the overall formula calculation ?

First, are you interested in a solution based on DRSteele's suggestion in the cited earlier thread, or based on my suggestion?
Apologies, I should have specified this in my original post. I am interested in expanding/using the solution that you had suggested in the post: Calculate XIRR for a specific "item" from a table that's sorted by date (i.e. post #3) as I don't want the solution to be limited only to Office365.


Second, when you say ``I want to combine [...] into a single table``, do you mean that you will __manually__ combine all data into a single table?

Or do you mean that you want the __formula__ to treat your separate tables as one combined table automagically?(!)

BTW, it is not necessary for the data to be sorted, except that for each account, in would be convenient if the first transaction appears before all of the other transactions for that account.

The XIRR function does not require data to be ordered by date, except that the first date is treated as the "present value" date. It must be earliest cash flow.

-----
I have the transactions data (not the XIRR) for each account separately and will manually combine them in a single table. The XIRR is to be calculated via a formula and I want the XIRR to be calculated for a specific account (kinda similar to your solution in post #3 but with the added complexity of having the final 'value' entry for XIRR calculation in a different column).

Finally, please provide an example of the combined tables, __and__ how you will provide "a specific account", __and__ what you mean by "the" correct XIRR.

In the example in the cited earlier thread, the "specific account" was in a cell that is separate from the data table, and I relied on a parallel helper cell to simplify the XIRR formula.

Moreover, only one XIRR is calculated for each "specific account", namely the XIRR for all cash flows related to the "specific account".

In contrast, in your original examples, you are calculating a "running" XIRR for __each__ closing balance, on an "ongoing basis", as you write. That is, it is not "the" single correct XIRR; instead, it is __multiple__ XIRRs for each account.

Also, would all the data for each account be together in the combined table, effectively concatenating each separate table?

Or would cash flows for different accounts be interleaved, perhaps ordered by date, not by account?
Book2
BCDEFGHIJ
2AccountDateParticularsEmployee Contribution ($)Employer's Contribution ($)Total ($)Total Fund ValueXIRRCorrect XIRR
3Account-1XY18-Jan-2018By Contribution$840.40$0.00$840.40 
4Account-2AB18-Jan-2018Tier-2 Contribution$2,076.40$0.00$2,076.40 
5Account-1XY31-Mar-2018Closing Balance$804.160.00%-20.02%
6Account-2AB31-Mar-2018Closing Balance$1,970.11-86.32%-23.39%
7Account-1XY3-Apr-2018By Contribution$5,976.40$0.00$5,976.40 
8Account-2AB3-Apr-2018Tier-2 Contribution$4,976.40$0.00$4,976.40 
9Account-1XY29-Jun-2018Closing Balance$6,862.690.00%2.58%
10Account-2AB29-Jun-2018Closing Balance$6,926.560.00%-5.87%
11Account-1XY28-Sep-2018Closing Balance$6,944.000.00%3.67%
12Account-2AB28-Sep-2018Closing Balance$7,085.450.00%0.85%
13Account-1XY31-Dec-2018Closing Balance$7,023.850.00%3.96%
14Account-2AB31-Dec-2018Closing Balance$7,172.040.00%2.10%
15Account-1XY31-Mar-2019Closing Balance$7,341.500.00%7.56%
16Account-2AB31-Mar-2019Closing Balance$7,579.570.00%7.08%
17Account-1XY28-Jun-2019Closing Balance$7,392.990.00%6.65%
18Account-2AB28-Jun-2019Closing Balance$7,765.430.00%7.71%
19Account-1XY30-Sep-2019Closing Balance$7,288.550.00%4.50%
20Account-2AB30-Sep-2019Closing Balance$7,751.810.00%6.27%
21Account-1XY31-Dec-2019Closing Balance$7,610.960.00%6.42%
22Account-2AB31-Dec-2019Closing Balance$8,066.270.00%7.72%
23Account-1XY24-Feb-2020By Contribution$4,976.40$0.00$4,976.40 
24Account-2AB24-Feb-2020Tier-2 Contribution$4,976.40$0.00$4,976.40 
25Account-1XY18-Mar-2020By Voluntary Contributions$25,000.00$0.00$25,000.00 
26Account-1XY31-Mar-2020Closing Balance$35,550.370.00%-8.51%
27Account-2AB31-Mar-2020Closing Balance$10,336.730.00%-12.01%
28Account-1XY30-Jun-2020Closing Balance$40,585.880.00%14.94%
29Account-2AB30-Jun-2020Closing Balance$11,917.060.00%-0.63%
30Account-1XY30-Sep-2020Closing Balance$43,211.200.00%18.12%
31Account-2AB30-Sep-2020Closing Balance$12,680.750.00%3.04%
32Account-1XY31-Dec-2020Closing Balance$51,260.763.58%30.33%
33Account-2AB31-Dec-2020Closing Balance$14,861.620.00%10.88%
34Account-1XY23-Mar-2021By Voluntary Contributions$1,500.00$0.00$1,500.00 
35Account-2AB23-Mar-2021Tier-2 Contribution$1,500.00$0.00$1,500.00 
36Account-1XY31-Mar-2021Closing Balance$54,652.753.51%27.95%
37Account-2AB31-Mar-2021Closing Balance$17,054.770.00%11.83%
sample data (2)
Cell Formulas
RangeFormula
I3:I37I3=IFERROR(XIRR(IF(ROW($C$3:C3)=ROW(C3), -H3)+$G$3:G3, $C$3:C3),"")
Press CTRL+SHIFT+ENTER to enter array formulas.

I hope the above example helps clarify what I am trying to achieve.
I am trying to get a 'running' XIRR specific to each account...I have added another column (column J) with the XIRR data pasted as values (from both source tables) before sorting the combined dataset by date. Essentially, Column J is what I am trying to achieve via a formula that I can drag down.
 
Upvote 0
I hope the above example helps clarify what I am trying to achieve.

Perfectly! Must be brief; in a rush. Sorry.

Enter the following formula in K3 and copy down the column:

=MATCH(B3,B:B,0)

Array-enter the following formula into I3 and copy down the column:

Rich (BB code):
=IF(H3="", "",
XIRR(IF(INDEX(B:B, K3):B3=B3, IF(ROW(INDEX(B:B, K3):B3)=ROW(B3), -H3) + INDEX(G:G, K3):G3, 0), INDEX(C:C, K3):C3))

If you do not want the "helper" values in column K, replace each instance of K3 with the MATCH(B3,B:B,0) in the second formula.
 
Upvote 0
Solution
Perfectly! Must be brief; in a rush. Sorry.

Enter the following formula in K3 and copy down the column:

=MATCH(B3,B:B,0)

Array-enter the following formula into I3 and copy down the column:

Rich (BB code):
=IF(H3="", "",
XIRR(IF(INDEX(B:B, K3):B3=B3, IF(ROW(INDEX(B:B, K3):B3)=ROW(B3), -H3) + INDEX(G:G, K3):G3, 0), INDEX(C:C, K3):C3))

If you do not want the "helper" values in column K, replace each instance of K3 with the MATCH(B3,B:B,0) in the second formula.
You are awesome!!!?

Many thanks!!!, your solution works perfectly and I am even able to understand how it works ?
 
Upvote 0
I am trying to do the same thing - calculate a rolling XIRR for an investment portfolio using 2 tables (one of transactions and the other consisting of monthly values for each stock in the portfolio).
I figure I can use Power Query to merge the two tables.
This solution is quite elegant, but I'm trying to figure out how to do the same thing only using Power Pivot/DAX instead.
Any help would be appreciated.
Thanks
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,442
Members
448,898
Latest member
drewmorgan128

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