I am struggling to recreate the following Excel logic in DAX:
Cont
and CF
are both data columns (sourced from SQL database), while
You cannot recursively self-reference a column in DAX.
See this related question: Recursion in DAX
However, for this particular case, you can create a closed-form formula for the column you want by realizing that for year N, the result you want can be written as
A * AR^N + sum_(i=1)^N AR^(N-i) (Cont_i - CF_i)
In DAX this can be written as follows (where Yr = N
and JP[Year] = i
):
mA =
VAR AR = 1.03
VAR Yr = SELECTEDVALUE ( JP[Year] )
VAR Temp =
ADDCOLUMNS (
FILTER ( ALL ( JP ), JP[Year] <= Yr ),
"Const", ( JP[Cont] - JP[CF] ) * POWER ( AR, Yr - JP[Year] )
)
RETURN
A[Parameter Value] * POWER ( AR, Yr ) + SUMX ( Temp, [Const] )
If you're starting with 2021, then you'll need to subtract 2020 from the Yr
variable.