> For the complete documentation index, see [llms.txt](https://docs.fabricplan.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fabricplan.com/planning-sheets/reference/formula-syntax/time-intelligence-functions/relative-time-periods.md).

# Relative time periods

Use the functions in this section to retrieve data relative to the current day, month, quarter, or year. Plan supports relative time period functions that help you analyze historical and future data by selecting a specified number of preceding or following time periods.

### LASTNDAY

The *LASTNDAY* function returns a range of dates for the specified number of days preceding the current day. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
LASTNDAY(number_of_days)
```

#### Arguments

* `number_of_days`: The number of preceding days for which data is returned.

#### Return value

Returns a range of dates for the specified number of preceding days.

#### Example

```
LASTNDAY(45)
```

Returns the date range for the 45 days preceding the current day.<br>

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FGh0msqlD5pixVZM0YZ22%2Fimage.png?alt=media&amp;token=c343e72d-a5c7-4641-8c9c-97d2652163d5" alt=""><figcaption></figcaption></figure>

### LASTNMONTH

The *LASTNMONTH* function returns a range of dates for the specified number of months preceding the current month. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
LASTNMONTH(number_of_months)
```

#### Arguments

* `number_of_months`: The number of preceding months for which data is returned.

#### Return value

Returns a range of dates for the specified number of preceding months.

#### Example

```
LASTNMONTH(15)
```

Returns the date range for the 15 months preceding the current month.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FuOViDfEegU2zCg5kHLrZ%2Fimage.png?alt=media&amp;token=bfed404b-4248-4094-9bd3-67cf0454d861" alt=""><figcaption></figcaption></figure>

### LASTNQTR

The *LASTNQTR* function returns a range of dates for the specified number of quarters preceding the current quarter. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
LASTNQTR(number_of_quarters)
```

#### Arguments

* `number_of_quarters`: The number of preceding quarters for which data is returned.

#### Return value

Returns a range of dates for the specified number of preceding quarters.

#### Example

```
LASTNQTR(5)
```

Returns the date range for the 5 quarters preceding the current quarter. In the following example, it returns the sum of *Sales* from *2025 Q2* to *2026 Q2*, which represents the five quarters preceding the current quarter (*2026 Q3*).

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FpDGZ48dj48xiHvMUQqMZ%2Fimage.png?alt=media&amp;token=7ae2dfdf-4c4b-434c-a297-faf80b68140f" alt=""><figcaption></figcaption></figure>

<figure><img src="https://github.com/lumelinc/PowerTableDocs/blob/main/.gitbook/assets/image%20(577).png" alt=""><figcaption></figcaption></figure>

### LASTNYEAR

The *LASTNYEAR* function returns a range of dates for the specified number of years preceding the current year. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
LASTNYEAR(number_of_years)
```

#### Arguments

* `number_of_years`: The number of preceding years for which data is returned.

#### Return value

Returns a range of dates for the specified number of preceding years.

#### Example

```
LASTNYEAR(2)
```

Returns the date range for the 2 years preceding the current year.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FMN9wT16vRpLlFmZ2VfiD%2Fimage.png?alt=media&amp;token=86df744d-644a-43db-8999-dc479fcc53c5" alt=""><figcaption></figcaption></figure>

### NEXTNDAY

The *NEXTNDAY* function returns a range of dates for the specified number of days following the current day. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
NEXTNDAY(number_of_days)
```

#### Arguments

* `number_of_days`: The number of following days for which data is returned.

#### Return value

Returns a range of dates for the specified number of following days.

#### Example

```
NEXTNDAY(45)
```

Returns the date range for the 45 days following the current day.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2Fsl7Kusk6f8iDiQQmmZEc%2Fimage.png?alt=media&amp;token=8aea6c72-3b03-4d9f-85c3-787dab94adf2" alt=""><figcaption></figcaption></figure>

### NEXTNMONTH

The *NEXTNMONTH* function returns a range of dates for the specified number of months following the current month. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
NEXTNMONTH(number_of_months)
```

#### Arguments

* `number_of_months`: The number of following months for which data is returned.

#### Return value

Returns a range of dates for the specified number of following months.

#### Example

```
NEXTNMONTH(4)
```

Returns the date range for the 4 months following the current month. For example, if the current month is **July**, it returns the aggregated sales for **August**, **September**, **October**, and **November**.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2F8aYsSemsCpJwoy5Q9NPo%2Fimage.png?alt=media&amp;token=cede36dc-e279-41c6-86d0-78caea4f351a" alt=""><figcaption></figcaption></figure>

### NEXTNQTR

The *NEXTNQTR* function returns a range of dates for the specified number of quarters following the current quarter. Use this function with the `SELECT.BYDATE` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
NEXTNQTR(number_of_quarters)
```

#### Arguments

* `number_of_quarters`: The number of following quarters for which data is returned.

#### Return value

Returns a range of dates for the specified number of following quarters.

#### Example

```
NEXTNQTR(2)
```

Returns the date range for the two quarters following the current quarter.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FHgaSp0g4uXI8qMmPweFq%2Fimage.png?alt=media&amp;token=e08f340b-0a83-40f9-9da2-524c846450e0" alt=""><figcaption></figcaption></figure>

### NEXTNYEAR

The *NEXTNYEAR* function returns a range of dates for the specified number of years following the current year. Use this function with the `SELECT` function and an aggregate function, such as `SUM` or `AVERAGE`, to retrieve and aggregate data over the returned date range.

#### Syntax

```
NEXTNYEAR(number_of_years)
```

#### Arguments

* `number_of_years`: The number of following years for which data is returned.

#### Return value

Returns a range of dates for the specified number of following years.

#### Example

```
NEXTNYEAR(2)
```

Returns the date range for the two years following the current year.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FvmKJptR11ZW3tyanNrrJ%2Fimage.png?alt=media&amp;token=4307a5a6-02bf-4372-a2ec-ea4d1a5b95e3" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.fabricplan.com/planning-sheets/reference/formula-syntax/time-intelligence-functions/relative-time-periods.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
