+ Reply to Thread
Results 1 to 14 of 14

Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

  1. #1
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Dear Forum,

    I am trying to calculate the XIRR for Multiple Investments done over different dates and stored in non-contagious rows and the last value of the investment in a different column.
    The XIRR requires the basic 2 Arguments the Amounts and Dates, however in my case the data is extracted from an Application where the Data is SORTED basis the Investment Date as there are Multiple Investments done in different Mutual Funds its difficult to get a continuous range to pass in the XIRR Function also the Latest Value of the Investment is not withdrawn but a notional amount which is a separate column so can something be done to use the XIRR Function for each Mutual Fund Separately.

    Without Sorting the Data, can this be achieved using Formulae also if any VBA option would also be Welcome which can Joi the Multiple Non-Contiguous Ranges and Column Ranges to be used in XIRR.

    Please find my attached file for reference.

    Thanking you in anticipation.

    Regards
    e4excel
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    689

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Could you first pls upload sample data without the circular in Column E, so we can be sure the base data is correct?

  3. #3
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,419

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    suppose you want to add the green values to those arrays !
    Please Login or Register  to view this content.
    if you need this calculation several times, you can make an UDF (User Defined Function) of it.
    Attached Files Attached Files
    Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

  4. #4
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    The Actual Data is from the COlumns A:E, in order to use the XIRR Function I made a sample from the actual data to show how the value would need to be derived..

  5. #5
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Consider those values as actual values and ignore the formula, thats the data which I get from the Application but in order to use the XIFF Function I have to arrange the data in the specific order for any Fund Name as shown in the Columns H : L

  6. #6
    Valued Forum Contributor
    Join Date
    07-13-2021
    Location
    California, USA
    MS-Off Ver
    2010
    Posts
    513

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    See the formulas in H12:J23 in the attached Excel file.

    The XIRR formula in I13 that corresponds to your calculation in I9 is:
    Please Login or Register  to view this content.
    The XIRR formula in J13 that corresponds to your calculation in I10 is:
    Please Login or Register  to view this content.
    Note that the ranges 2:35 and 2:36 purposely reference 1 and 2 rows, respectively, below the table of cash flows (2:34). In contrast, the range 2:34 is sufficient for the INDEX/MATCH.

    The formulas must be array-entered (press ctrl+shift+Enter) in Excel 2010 and some other versions of Excel.

    They can be simplified in Office Excel 365 and perhaps some later versions of Excel by using a LET function to calculate the MATCH index only once.

    (Further simplification might be possible by using new functions in recent versions of Excel. I am not familiar with them.)

    As "proof of concept", compare with the formulas in N1:AI39.

    Note: In order to use the Excel file in your posting #1, I replaced the circular-reference formulas in column E with constants.
    Attached Files Attached Files
    Last edited by curiouscat408; 11-21-2021 at 04:07 PM. Reason: minor typos

  7. #7
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Please try at I10

    PHP Code: 
    =XIRR(IF(INDEX($A$2:$A$35,MATCH(H10,$A$2:$A$35,)):$A$35=H10,INDEX($C$2:$C$35,MATCH(H10,$A$2:$A$35,)):$C$35,IF(INDEX($A$2:$A$35,MATCH(H10,$A$2:$A$35,)):$A$35=0,VLOOKUP(H10,$A$2:$E$34,5,0),0)),IFERROR(1/(1/INDEX($B$2:$B$35,MATCH(H10,$A$2:$A$35,)):$B$35),VLOOKUP(H10,$A$2:$E$34,4,0))) 
    Confirm with Ctrl+Shift+Enter

    H10:Hxx => Fund 1 - xx
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    01-25-2011
    Location
    Belgium, Alveringem
    MS-Off Ver
    Excel 2003, 2007, 365
    Posts
    1,419

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    impressive, twice
    Last edited by bsalv; 11-21-2021 at 04:19 PM.

  9. #9
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    UK
    MS-Off Ver
    365
    Posts
    689

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Wow Bo_Ry, that looks so elegant and simple.
    To be honest, I am not sure I was fully aware that ranges can be constructed this way with a simple IF statement.

  10. #10
    Valued Forum Contributor
    Join Date
    07-13-2021
    Location
    California, USA
    MS-Off Ver
    2010
    Posts
    513

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    @Bo_Ry, I like INDEX($A$2:$A$35,MATCH(H10,$A$2:$A$35,0)):$A$35=H10 as a simplification.

    However, I suspect that we need something like ROW($A$2:$A$36)=ROW($A$35) and similarly for ROW($A$36) for the second XIRR that e4excel calculates in I10. Right?

    -----

    And beware of expressions like 1/(1/INDEX($B$2:$B$35,MATCH(H10,$A$2:$A$35,0)).

    Although the double-inverse of an integer results in the same integer mathematically, that is not always the case in binary floating-point arithmetic.

    For example, with 9/4/1989 or 3/30/2027 in A1, MATCH(1/(1/A1),A1,0) returns #N/A, indicating that the binary values do not match.

    OTOH, the difference is infinitesimal. And I have not found a case where 1/(1/A1)=A1 returns FALSE. Thus, the values match when rounded to 15 significant digits (so far).

    So it might not be a problem in this context. But it is something to keep in mind in other contexts.

    The work-around is simple: use ROUND(1/(1/A1),0).

    FYI, I have not found a case where INT(1/(1/A1)) does not work equally well. And that might be faster (we're talking about nanoseconds!). But ROUND is safer, IMHO.
    Last edited by curiouscat408; 11-21-2021 at 06:14 PM. Reason: minor typos

  11. #11
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,222

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    I am aware that double-inverse could cause non-match due to floating-point.

    But for XIRR calculation, Dates only take integers.

    I can +0.1 or + 0.9 to the Dates without any difference in XIRR result
    IFERROR(1/(1/INDEX($B$2:$B$35,MATCH(H10,$A$2:$A$35,)):$B$35),VLOOKUP(H10,$A$2:$E$34,4,0))+0.1
    IFERROR(1/(1/INDEX($B$2:$B$35,MATCH(H10,$A$2:$A$35,)):$B$35),VLOOKUP(H10,$A$2:$E$34,4,0))+0.9

    So floating-point cause nothing in this context
    Attached Files Attached Files

  12. #12
    Valued Forum Contributor
    Join Date
    07-13-2021
    Location
    California, USA
    MS-Off Ver
    2010
    Posts
    513

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Quote Originally Posted by Bo_Ry View Post
    So floating-point cause nothing in this context
    Which is exactly what I wrote, to wit: ``it might not be a problem in this context. But it is something to keep in [mind] in other contexts``.

    (Hmm, I just notice the typo!)

    I see the double-inverse paradigm used by "experts" often. And the thread is read by others, who might find the paradigm appealing, but who might not be aware of the math-v-binary arithmetic differences.

    My comment was just a heads-up.
    Last edited by curiouscat408; 11-21-2021 at 06:15 PM.

  13. #13
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Dear Bo_Ry,

    Hats Off To You...Its exactly what I was looking for however can you please explain it a little bit as I have never used such references in an Index Function...also I am trying to figure out as to why is the Range till ROW-35 which is blank , Is it house the extra information on the FInal Value stored in the different column..

    Thanks a ton..

  14. #14
    Registered User
    Join Date
    11-03-2008
    Location
    India
    MS-Off Ver
    Excel 2010
    Posts
    2,521

    Re: Calculating XIRR on Non-Contiguous Rows and Columns based on Criteria

    Thank you so much Mr Curious... you too have given a good solution however I would prefer the more compact one ofcourse but nonetheless your efforts too are much appreciated..

    Thank you so much...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Help in calculating XIRR for entries from different columns
    By rishiambekar in forum Excel General
    Replies: 14
    Last Post: 09-13-2019, 12:02 AM
  2. XIRR for non contiguous arrays
    By Alexander_Golinsky in forum Excel General
    Replies: 3
    Last Post: 07-13-2012, 05:15 AM
  3. [SOLVED] XIRR for non contiguous arrays
    By Alexander_Golinsky in forum Excel General
    Replies: 1
    Last Post: 07-12-2012, 12:06 PM
  4. Calculating Contiguous Columns by Using the Column Number
    By SDruley in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-07-2011, 02:09 PM
  5. [SOLVED] XIRR & non-Contiguous Values?
    By bluepost22@yahoo.com in forum Excel General
    Replies: 11
    Last Post: 06-24-2010, 03:11 AM
  6. XIRR and Non Contiguous Cells
    By John Taylor in forum Excel General
    Replies: 3
    Last Post: 08-01-2006, 07:50 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1