Dynamic XIRR with zeros the numbers

wspphish123

New Member
Joined
Sep 19, 2018
Messages
3
Hi all - I am trying to use the xirr function but running into challenges. I am a series’s of dates starting in A1, and series of cashflow in B1. The challenge I am running into is that if I have zeros in the first cell then negative for outflow before inflow starts, excel doesn’t calculate the irr. Any suggestion for using index match or offset to make it dynamic so I am not having to drag to the array of cash flows?! Thanks
 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
If your on a recent version (16/365) then this sounds like an ideal application of the filter function (please see help for full description). You can either use this directly embedded within your xirr function, or enter it as an additional output range - passing the first cell reference followed by “#” (which tells excel to pass the entire spill range) into xirr. The first approach is more compact, but might be worth doing it the second way until you are sure the filter function is doing what you want, and then embed it inside…

Hth

Ben
 
Upvote 0
Thank you for responding to this. Can you please provide an equation for this? I keep getting o% in E6. Thanks a bunch!

1642183097637.png
 
Upvote 0
No I’m afraid not - I’m more a teach a man to fish (or at least point him toward a lake). So you have tried to use the xirr function on a test data set I hope and got the result you expect. Next use the filter function to try and select the data as you expect xirr to require. Then join the two together. Someone else may be along…
 
Upvote 0
Here's a version that computes the XIRR based on the first non-zero value in the range. It's very sensitive to how you have your data organized, so if have a different layout, let me know. Also, please update your user profile with the version of Excel you're using.

Book1 (version 2).xlsb
ABCDEFGHIJKLMNOPQRS
1
2
31/1/20213/1/20215/1/20217/1/20219/1/202111/1/20211/1/20223/1/20225/1/20227/1/20229/1/202211/1/20221/1/20237/1/2025
400000-20001010105220300
5
60%
721%
8
921%
Sheet12
Cell Formulas
RangeFormula
F6F6=XIRR(F4:S4,F3:S3)
F7F7=XIRR(K4:S4,K3:S3)
F9F9=XIRR(INDEX(4:4,AGGREGATE(15,6,COLUMN(F4:S4)/(F4:S4<>0),1)):S4,INDEX(3:3,AGGREGATE(15,6,COLUMN(F4:S4)/(F4:S4<>0),1)):S3)
 
Upvote 0
this is awesome, thank you! it works. just curious. why do you have to do the array of 3:3 or 4:4 and what is the 15 or 6 for in the equation?

sometimes i realize excel is just an amazing tool. learn something new every day. Thank you!!
 
Upvote 0
Maybe it would be a bit clearer if I wrote it like this:

=XIRR(INDEX(F4:S4,AGGREGATE(15,6,(COLUMN(F4:S4)-COLUMN(F4)+1)/(F4:S4<>0),1)):S4,INDEX(F3:S3,AGGREGATE(15,6,(COLUMN(F4:S4)-COLUMN(F4)+1)/(F4:S4<>0),1)):S3)

In this version I used the actual ranges instead of using 3:3 and 4:4, which are shortcut descriptions of saying "row 3" and "row 4". The original formula used COLUMN(F4:S4) to look at the column numbers of your range, then when it found the smallest column with a non-zero amount, plugged it into the row. The one I just posted uses the offset into the range, COLUMN(F4:S4)-COLUMN(F4)+1. The first way is a bit shorter, but the second may be clearer.

As far as the 15 and 6, they are parameters to the AGGREGATE function. AGGREGATE actually is a collection of several different functions. 15 means LEAST, and 6 means to ignore any error values in the list. I used AGGREGATE instead of LEAST because LEAST won't ignore errors, which I intentionally introduced by dividing by (F4:S4<>0).

Anyway, glad I could help!
 
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