Forum Discussion
Rate of change - DAX code
- 3 years ago
Solution:
I was close with using parallelperiod.
When i used lastdate with it, it pulled through the one month i needed and the rest worked.
With it set to -1 it will pull the lastdate -1 month (as I specifcied month in the parallperiod).
This solution gives the freedom to set any number of days/months/years.
The solution will also allow for user input if you tweak the -1 to a variable that reads user input.New rate Delta = var minus_1_dates = CALCULATE(LASTDATE(PARALLELPERIOD(Dates[Date],-1,MONTH))) return CALCULATE(Append1[new_rate],Dates[Date]=minus_1_dates)
Solution:
I was close with using parallelperiod.
When i used lastdate with it, it pulled through the one month i needed and the rest worked.
With it set to -1 it will pull the lastdate -1 month (as I specifcied month in the parallperiod).
This solution gives the freedom to set any number of days/months/years.
The solution will also allow for user input if you tweak the -1 to a variable that reads user input.
New rate Delta =
var minus_1_dates = CALCULATE(LASTDATE(PARALLELPERIOD(Dates[Date],-1,MONTH)))
return
CALCULATE(Append1[new_rate],Dates[Date]=minus_1_dates)