Date.IsInNextNYears

Date

Returns true if the date falls within the next N calendar years.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Date.IsInNextNYears(dateTime as any, years as number) as logical

Parameters

NameTypeRequiredDescription
dateTimeanyYesA date, datetime, or datetimezone value to test.
yearsnumberYesThe number of years ahead to include. Must be a positive integer.

Return Value

logicaltrue if the date falls within the next N years after the current year, false otherwise.

Remarks

Date.IsInNextNYears returns true if the input date falls within the next N complete calendar years after the current year. The current year itself is not included; use Date.IsInCurrentYear to also match the current year. The function is re-evaluated on each query refresh.

For example, if the current year is 2026 and years = 3, it matches any date in 2027, 2028, or 2029. This function counts whole calendar years (January 1 through December 31), not a rolling 365-day window. For a rolling window, use Date.IsInNextNDays(n * 365) or compute the boundary dates explicitly.

Use this function for medium-term planning scenarios such as multi-year contract expiration reporting, asset replacement schedules, or budget forecasting horizons.

Examples

Example 1: Find orders due in the next 2 years

Table.SelectRows(
    Sales,
    each Date.IsInNextNYears([OrderDate], 2)
)
Result
OrderID
CustomerName
OrderDate
150Alice3/15/2027
251Bob9/22/2027

Example 2: Flag long-term orders

Table.AddColumn(
    Sales,
    "DueInNext5Years", each Date.IsInNextNYears([OrderDate], 5), type logical
)
Result
OrderID
OrderDate
DueInNext5Years
1423/8/2026FALSE
2503/15/2027TRUE
3551/1/2032FALSE

Example 3: Combine current year and next 2 years for a 3-year view

Table.SelectRows(
    Sales,
    each Date.IsInCurrentYear([OrderDate]) or Date.IsInNextNYears([OrderDate], 2)
)
Result
OrderID
CustomerName
OrderDate
142Charlie3/8/2026
250Alice3/15/2027
351Bob9/22/2027

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks