Forum Discussion
Solution to XIRR with Terminal Values
Hi austinsense,
Thanks for your post. I found it somewhat helpful, although I have made my own code to deal with a similar problem. I wanted to find what my rolling IRR is for every date instead of a specific date. Also in the dataset, I have a number of different assets (Name), that I need to seperately calculate rolling IRRs for, adding an additional level of complexity.
Fianlly, I have included a couple of checks to ensure that the formula will not error if data is queried that cannot be used in the IRR calculation. These checks include:
- checking to ensure that the first value in the column is a negative, and
- ensuring there is at least one positive and one negative value in the dataset.
A big thanks to v-ljerr-msft for their help!!
Cheers,
MJ
ROLLING XIRR =
VAR countpos =
CALCULATE(
COUNT('INVESTMENT RETURNS'[totalcashflow]),
FILTER(ALL('INVESTMENT RETURNS'), 'INVESTMENT RETURNS'[totalcashflow]>0 && EARLIER ('INVESTMENT RETURNS'[Index] ) >= 'INVESTMENT RETURNS'[Index] && 'INVESTMENT RETURNS'[Name] = EARLIER ( 'INVESTMENT RETURNS'[Name] )
)
)
VAR minIndex =
CALCULATE (
MIN ( 'INVESTMENT RETURNS'[Index] ),
FILTER (
ALL ( 'INVESTMENT RETURNS' ),
'INVESTMENT RETURNS'[Name] = EARLIER ( 'INVESTMENT RETURNS'[Name] )
)
)
VAR firstValue =
CALCULATE (
MIN ( 'INVESTMENT RETURNS'[FREE CASHFLOW FOR PERIOD (excl. sale)] ),
FILTER (
ALL ( 'INVESTMENT RETURNS' ),
'INVESTMENT RETURNS'[Name] = EARLIER ( 'INVESTMENT RETURNS'[Name] )
&& 'INVESTMENT RETURNS'[Index] = minIndex
)
)
RETURN
IF (
'INVESTMENT RETURNS'[Index] > minIndex
&& firstValue < 0
&& countpos >= 1 ,
XIRR (
UNION(
SUMMARIZE(
FILTER(ALL ( 'INVESTMENT RETURNS' ), EARLIER ('INVESTMENT RETURNS'[Index] ) >= 'INVESTMENT RETURNS'[Index] && 'INVESTMENT RETURNS'[Name] = EARLIER ( 'INVESTMENT RETURNS'[Name] ))
,'INVESTMENT RETURNS'[Index],
"DATE1",MAX('INVESTMENT RETURNS'[DATE]),
"CASHFLOW",MAX('INVESTMENT RETURNS'[FREE CASHFLOW FOR PERIOD (excl. sale)])
),
SUMMARIZE(
FILTER(ALL ( 'INVESTMENT RETURNS' ), EARLIER ('INVESTMENT RETURNS'[Index] ) = 'INVESTMENT RETURNS'[Index] ),
'INVESTMENT RETURNS'[Index],
"DATE1",MAX('INVESTMENT RETURNS'[DATE]),
"CASHFLOW",MAX('INVESTMENT RETURNS'[EQUITY REPAYMENT/(INVESTMENT) ON SALE])
)
),
[CASHFLOW],
[DATE1]
)
)Hi mjfigg,
I am looking for exacly what you have described. I've copied your formulas bet get a number of errors including "Earlier/Earliest refers to an earlier row context which doesn't exist". Any chance you could proivide a copy/screenshot of your Source table and the Power BI File?
Thanks,
JS
- austinsense8 years agoImpactful Individual
This formula needs some re-work. I've been meaning to update it. Let me give it some work.