Forum Discussion
Calculated Column for delta calculation with previous row (lead/lag)
- 5 years ago
ferzfeld add new column using following expression:
Delta New = VAR __currentDate = Delta[entry_date] VAR __filter = ALLEXCEPT ( Delta, Delta[kpi_id],Delta[Notes] ) VAR __previousDate = CALCULATE ( MAX ( Delta[entry_date] ), __filter, Delta[entry_date] < __currentDate ) VAR __previousSales = CALCULATE ( MAX ( Delta[Actual] ), __filter, Delta[entry_date] = __previousDate ) RETURN IF ( NOT ISBLANK ( __previousSales ), Delta[Actual] - __previousSales )Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
ferzfeld add new column using following expression:
Delta New =
VAR __currentDate = Delta[entry_date]
VAR __filter = ALLEXCEPT ( Delta, Delta[kpi_id],Delta[Notes] )
VAR __previousDate =
CALCULATE (
MAX ( Delta[entry_date] ),
__filter,
Delta[entry_date] < __currentDate
)
VAR __previousSales =
CALCULATE (
MAX ( Delta[Actual] ),
__filter,
Delta[entry_date] = __previousDate
)
RETURN
IF ( NOT ISBLANK ( __previousSales ),
Delta[Actual] - __previousSales
)
Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
Wow this is amazing - providing exactly the result I have been looking for!
Thank you so much for your help, I really appreciate it 😊