# LASTNMONTH

The **LASTNMONTH** function can be used to select data from a given measure for a specified number of months preceding the start of the current month. It should be used in conjunction with the SELECT clause and with an aggregate function like SUM or AVERAGE.&#x20;

## Syntax

```javascript
LASTNMONTH(number_of_months)
```

## Arguments

number\_of\_months – The number of preceding months for which data has to be fetched. Required.

## Return value

Period Range.

## Example

```javascript
LASTNMONTH(15) 
//Returns data for the past 15 months preceding the start of the current month
```

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2Fyc9OZzUZEklz9e5SejFB%2Fimage.png?alt=media&#x26;token=19621f77-b1ce-40ef-9d5d-df84b8803503" alt=""><figcaption><p>LASTNMONTH</p></figcaption></figure>
