For the complete documentation index, see llms.txt. This page is also available as Markdown.

LastNPeriods

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.

Syntax

.LASTNPERIODS(n) - > [number]

Arguments

Arguments
Datatype
Description

n

Number

The integer that is less than the number of periods defined in the model.

Remarks

This function can only be used after referring a node for which this calculation needs to be done as shown below in the example.

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.

2022 Periods
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
Sep
Oct
Nov
Dec

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.

Result

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?