Forum Discussion
Recursive calculation with cumulated sums
Hello all,
I am struggling in Power Bi to compute the following formula (remain to engage)
RTE(m) = MAX [ sum[TSP] (m0 to m) - sum[AEFP] (m0 to m) -sum[RTE] (m0 to m-1) ; 0]
see example below
would you have any idea to solve this please ?
thank you for your support
regards
gen
| Month | Total Spend planned (TSP) | Already engaged for payment (AEFP) | Remain to engage (RTE) |
| 1 | 200 | 180 | 20 |
| 2 | 100 | 80 | 20 |
| 3 | 150 | 30 | 120 |
| 4 | 100 | 10 | 90 |
| 5 | 200 | 5 | 195 |
| 6 | 50 | 50 | |
| total | 800 | 305 | 495 |
2 Replies
- AlexisOlson
Super User
From your example, it looks like you can simply define RTE = TSP - AEFP (or maybe MAX( TSP - AEFP, 0 ) ).
Recursion in DAX is problematic in general but often you can find non-recursive ways of doing the computation. Check out this post for more detail: https://stackoverflow.com/questions/52766022/recursion-in-dax
- AnonymousNot applicable
actually my example was a little bit easy... it happens that the planned revised is below the already engaged..
in this case I need the max to avoid further engagement and make sure that month after month my cumul is valid