LastNPeriods
Syntax
Arguments
Arguments
Datatype
Description
Remarks
Example
2022 Periods
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec
Result
Last updated
Was this helpful?
The LASTNPERIODS function refers to the values of the node’s last ‘n’ periods. It will give the result as the last 'n' periods' value.
.LASTNPERIODS(n) - > [number]
n
Number
The integer that is less than the number of periods defined in the model.
This function can only be used after referring a node for which this calculation needs to be done as shown below in the example.
Consider a scenario where we have interest payments for Jan to Dec. Our objective is to calculate the interest paid in the last 6 months for each month.
Interest payments
0
78.37
74.06
69.71
65.33
60.91
56.46
51.96
47.43
42.86
38.26
33.61
To achieve this, the following formula should be written in the [Last 6 period's value] node:
SUM([Interest payments].LastNPeriods(6))
We give n as 6 since we want to calculate the last 6 months value. This will calculate the last 6 months value for each period. So for March it will add Jan & Feb, for April it will add Jan to Mar and so on.
Last 6 period's value
0
0
78.37
152.43
222.14
287.47
348.38
404.84
378.43
351.8
324.95
297.88
Last updated
Was this helpful?
Was this helpful?