Updated on

Date.IsInPreviousNWeeks is a Power Query M function that indicates whether the given date(time) value occurs during the previous number of weeks, as determined by the system. The function returns a boolean value (true or false).

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365


   dateTime as any,
   weeks as number,
) as nullable logical


Date.IsInPreviousNWeeks checks if dateTime (of type date, datetime, or datetimezone) falls within a specified number of weeks before the current system date and time, excluding the current week. It also includes a weeks argument to specify the number of weeks.


Determine if the week before the current system time is in the previous two weeks.

// Output: true
Date.IsInPreviousNWeeks( Date.AddDays( DateTime.FixedLocalNow(), -7 ), 2 )

Other functions related to Date.IsInPreviousNWeeks are:

BI Gorilla Youtube Channel

Contribute » | Contributors: Rick de Groot
Microsoft documentation: