Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago

Rolling XIRR per project

Dear All,

 

I'm trying to calculate the rolling IRR per project but I can't find a suitable query. I want an IRR that develops over time so I can see when the IRR goes from negative to positive. 

Query I used for the calculation for all projects (data I used is shown below the query):

Gross IRR =
VAR minIndex =
CALCULATE (
MIN ( 'TEST - Working Capital'[Index] )
, ALL ( 'TEST - Working Capital' ) )
RETURN
IF (
'TEST - Working Capital'[Index] > minIndex,
CALCULATE (
XIRR (
'TEST - Working Capital',
'TEST - Working Capital'[Cash flow amount],
'TEST - Working Capital'[Transaction Date]
),
FILTER (
allselected('TEST - Working Capital'),
MAX ( 'TEST - Working Capital'[Index] ) >= 'TEST - Working Capital'[Index]
)
)
)

Data:

Current Face/Funded AmountTransaction TypeTransaction DateSecurity/Facility HIDCash flowCash flow amountIndexGross IRR
€ 1.000.000Facility - Purchase1-7-201424639Cash flow - out1.000.000 -€9 
€ 1.000.000Loan - Interest Payment31-7-201424639Cash flow - in€ 194,44116,02%
€ 1.000.000Loan - Interest Payment31-8-201424639Cash flow - in€ 5.833,33186,02%
€ 1.000.000Loan - Interest Payment30-9-201424639Cash flow - in€ 5.833,33216,02%
€ 1.000.000Loan - Interest Payment31-10-201424639Cash flow - in€ 5.833,33296,02%
€ 1.000.000Loan - Interest Payment30-11-201424639Cash flow - in€ 5.833,33336,02%
€ 1.000.000Loan - Interest Payment31-12-201424639Cash flow - in€ 5.833,33376,02%
€ 1.000.000Loan - Interest Payment31-1-201524639Cash flow - in€ 5.833,33436,02%
€ 1.000.000Loan - Interest Payment28-2-201524639Cash flow - in€ 4.414,38546,02%
€ 1.000.000Loan - Interest Payment31-3-201524639Cash flow - in€ 4.414,38656,02%
€ 1.009.000Loan - Interest Payment30-4-201524639Cash flow - in€ 4.414,38716,02%
€ 1.009.000Facility - Commitment Increase30-4-201524639Cash flow - out9.000 -€726,02%
€ 1.009.000Loan - Interest Payment31-5-201524639Cash flow - in€ 4.414,37806,02%
€ 1.009.000Loan - Interest Payment30-6-201524639Cash flow - in€ 4.414,38886,02%
€ 1.009.000Loan - Interest Payment31-7-201524639Cash flow - in€ 4.414,38926,02%
€ 1.009.000Loan - Interest Payment31-8-201524639Cash flow - in€ 4.414,381036,02%
€ 1.009.000Loan - Interest Payment30-9-201524639Cash flow - in€ 4.414,381206,02%
€ 1.000.000Facility - Purchase1-10-201523922Cash flow - out1.000.000 -€1286,02%
€ 1.009.000Loan - Interest Payment31-10-201524639Cash flow - in€ 4.414,381296,02%
€ 1.000.000Loan - Interest Payment31-10-201523922Cash flow - in€ 5.416,671366,02%
€ 1.000.000Loan - Interest Payment30-11-201523922Cash flow - in€ 5.416,671456,02%
€ 1.009.000Loan - Interest Payment30-11-201524639Cash flow - in€ 4.414,381466,02%
€ 1.009.000Loan - Interest Payment31-12-201524639Cash flow - in€ 4.414,381676,02%
€ 1.006.000Loan - Interest Payment31-12-201523922Cash flow - in€ 5.416,671686,02%
€ 1.006.000Facility - Commitment Increase31-12-201523922Cash flow - out6.000 -€1706,02%
€ 1.006.000Loan - Interest Payment31-1-201623922Cash flow - in€ 5.449,171906,02%
€ 1.015.054Loan - Interest Payment31-1-201624639Cash flow - in€ 4.440,861916,02%
€ 1.015.054Facility - Commitment Increase31-1-201624639Cash flow - out6.054 -€1996,02%
€ 1.006.000Loan - Interest Payment29-2-201623922Cash flow - in€ 5.449,172076,02%
€ 1.015.054Loan - Interest Payment29-2-201624639Cash flow - in€ 4.440,862256,02%
€ 1.006.000Loan - Interest Payment31-3-201623922Cash flow - in€ 5.449,172286,02%
€ 1.015.054Loan - Interest Payment31-3-201624639Cash flow - in€ 4.440,862366,02%
€ 1.015.054Loan - Interest Payment30-4-201624639Cash flow - in€ 4.440,862496,02%
€ 1.006.000Loan - Interest Payment30-4-201623922Cash flow - in€ 5.449,172586,02%
€ 1.006.000Loan - Interest Payment31-5-201623922Cash flow - in€ 5.449,172746,02%
€ 1.015.054Loan - Interest Payment31-5-201624639Cash flow - in€ 4.440,862786,02%
€ 1.015.054Loan - Interest Payment30-6-201624639Cash flow - in€ 4.440,862936,02%
€ 1.006.000Loan - Interest Payment30-6-201623922Cash flow - in€ 5.449,173036,02%
€ 1.015.054Loan - Interest Payment31-7-201624639Cash flow - in€ 4.440,863166,02%
€ 1.006.000Loan - Interest Payment31-7-201623922Cash flow - in€ 5.449,173266,02%
€ 1.006.000Loan - Interest Payment31-8-201623922Cash flow - in€ 5.449,173406,02%
€ 0Facility - Paydown31-8-201624639Cash flow - in€ 1.015.0543436,02%
€ 0Loan - Interest Payment31-8-201624639Cash flow - in€ 3.256,633506,02%
€ 1.006.000Loan - Interest Payment30-9-201623922Cash flow - in€ 5.449,173736,02%
€ 1.006.000Loan - Interest Payment31-10-201623922Cash flow - in€ 5.449,174026,02%
€ 1.006.000Loan - Interest Payment30-11-201623922Cash flow - in€ 5.449,174286,02%
€ 1.007.006Loan - Interest Payment31-12-201623922Cash flow - in€ 5.449,174546,02%
€ 1.007.006Facility - Commitment Increase31-12-201623922Cash flow - out1.006 -€4656,02%
€ 1.007.006Loan - Interest Payment31-1-201723922Cash flow - in€ 5.454,624866,02%
€ 1.007.006Loan - Interest Payment28-2-201723922Cash flow - in€ 5.454,625126,02%
€ 1.007.006Loan - Interest Payment31-3-201723922Cash flow - in€ 5.454,625596,02%
€ 1.007.006Loan - Interest Payment30-4-201723922Cash flow - in€ 5.454,625746,02%
€ 1.007.006Loan - Interest Payment31-5-201723922Cash flow - in€ 5.454,626016,02%
€ 1.007.006Loan - Interest Payment30-6-201723922Cash flow - in€ 5.454,626346,02%
€ 0Loan - Interest Payment31-7-201723922Cash flow - in€ 3.818,236516,02%
€ 0Facility - Paydown31-7-201723922Cash flow - in€ 1.007.0066626,02%

8 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;

    You could try to create a column as follow:

    Gross IRR3 = 
    VAR minIndex =
        CALCULATE (
            MIN ( 'TEST - Working Capital'[Index] ),
            ALL ( 'TEST - Working Capital' )
        )
    RETURN
        IF (
            'TEST - Working Capital'[Index] > minIndex,
            CALCULATE (
                XIRR (
                    'TEST - Working Capital',
                    'TEST - Working Capital'[Cash flow amount],
                    'TEST - Working Capital'[Transaction Date]
                ),
                FILTER (
                    ALLSELECTED ( 'TEST - Working Capital' ),
                  EARLIER( 'TEST - Working Capital'[Index] ) >= 'TEST - Working Capital'[Index]
                )
            )
        )
    

    The final show:

    For reference:

     

    Rolling XIRR Calculation

     

    XIRR in differents periods

     

    Solution to XIRR with Terminal Values


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Yalan Wu,

       

      Thank you for your reply. It's unfortunately not working with my pbix file. I do exactly the same but I still got an error. What do I do wrong?
      Next to this, this is not per project (column Security/Facility HID). For now it's a rolling total. 

       

       

       

       

       



  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ,

    May be ALLSELECTED();

    If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.

    How to upload PBI in Community


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous ;
    You data is can't return vaild, if i change one value and filter little data,it will correct,

     

     XIRR Function (DAX) states: If the calculation fails to return a valid result, an error or value specified as alternateResult is returned.

    https://www.microsoft.com/videoplayer/embed/RWLzrC

    Or change it .

    Gross IRR3 = 
    VAR minIndex =
        CALCULATE (
            MIN ( 'TEST - Working Capital'[Index] ),
            ALL ( 'TEST - Working Capital' )
        )
    RETURN
        IF (
            'TEST - Working Capital'[Index] > minIndex,
            CALCULATE (
                XIRR (
                    'TEST - Working Capital',
                    'TEST - Working Capital'[Cash flow amount],
                    'TEST - Working Capital'[Transaction Date],0.1,-0.99
                ),
                FILTER (
                    ALLSELECTED ( 'TEST - Working Capital' ),
                  EARLIER( 'TEST - Working Capital'[Index] ) >= 'TEST - Working Capital'[Index]
                )
            )
        )
    


    Best Regards,
    Community Support Team _ Yalan Wu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi v-yalanwu-msft ,

       

      Why can't my data return valid? The data I send in the message above is exactly the same as in the shared pbix file and you got no error but I do got an error.

      Regards, Toon