# LASTNYEAR

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

## Syntax

```javascript
LASTNYEAR(number_of_years)
```

## Arguments

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

## Return value

Period Range.

## Example

```javascript
LASTNYEAR(2) 
//Returns data for 2 years preceding the start of the current year
```

<figure><img src="https://3062809325-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEbkCXCUXmtUq5tcnUtZE%2Fuploads%2FtbHO7BURkaZ7rzEwpUph%2Fimage.png?alt=media&#x26;token=899553e6-87be-48fc-949b-474f165803d0" alt=""><figcaption><p>LASTNYEAR</p></figcaption></figure>
