Filter and sort within XIRR?

dxg169

New Member
Joined
Sep 12, 2022
Messages
3
Office Version
  1. 365
  2. 2021
Hi all - I have a table of raw cashflow data which I'm hoping to do an XIRR formula on based on an inputted deal. However the raw cashflow data is not always sorted so that the first cashflow is negative. This causes issues with an XIRR formula

Example data in table below.

I was hoping to use this formula:
=XIRR(
FILTER(C:C,B:B=[deal X]), #Filter to obtain array of cashflows for [deal X]
FILTER(A:A,B:B=[deal X]), #Filter to obtain array of dates for [deal X]
0.1) #Guess for XIRR

However I get an error on Deal C as the cashflows are not in order. The +120 is before the -110.

I thought I could use the sort formula on the cashflows, but can't think how to ensure that the dates correctly align with those sorted cashflows.
For example I couldn't sort on both columns as for deal A the +10 would be 2nd in the sort, but the 01/08/2022 date corresponding for that cashflow would be 3rd in the sort.

Any help greatly appreciated.

DateDealCashflow
01/12/2019​
Deal A
-100​
01/12/2019​
Deal B
-120​
01/12/2021​
Deal C
120​
01/06/2022​
Deal A
150​
01/12/2020​
Deal B
130​
01/08/2022​
Deal A
10​
01/06/2019​
Deal C
-110​
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Try...

dxg.xlsm
ABCDEF
1DateDealCashflowResults
212/01/2019Deal A-100Deal A0.205782
312/01/2019Deal B-120Deal B0.083096
412/01/2021Deal C120Deal C0.035358
506/01/2022Deal A150
612/01/2020Deal B130
708/01/2022Deal A10
806/01/2019Deal C-110
Sheet1
Cell Formulas
RangeFormula
F2:F4F2=LET(rng,SORT(FILTER($A$2:$C$8,($B$2:$B$8=E2)),1,1,FALSE),XIRR(INDEX(rng,0,3),INDEX(rng,0,1),0.1))


Note that the formula is first entered in F2, and then copied down.

Hope this helps!
 
Upvote 0

Forum statistics

Threads
1,214,971
Messages
6,122,521
Members
449,088
Latest member
RandomExceller01

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