Date.IsInNextWeek

Updated on

Date.IsInNextWeek is a Power Query M function that indicates whether the given date(time) value occurs during the next week, 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

Syntax

Date.IsInNextWeek( dateTime as any ) as nullable logical

Description

Date.IsInNextWeek test if a given value (of type date, datetime, or datetimezone) falls within the upcoming week, based on the current system date and time, excluding current week values.

Examples

Let’s explore two straightforward examples to understand how the Date.IsInNextWeek function works.

Checking for Dates within the Next Week

Let’s say you have a calendar table and you want to add a column that marks dates as true if they fall within the next week. You can do this by using the Date.IsInNextWeek function on your [Date] column.

Date.IsInNextWeek( [Date] ) // Output depends on [Date] column

This expression returns true for any date in the [Date] column that falls within the next week.

For example, if today is July 6, 2024, this function will return true for all rows with dates between July 8, 2024, and July 14, 2024. Here’s a screenshot showing this:

Example of how to use the Date.IsInNextWeek function in Power Query M

You can see that dates within the next week are marked with true.

Using the Current Date and Time

To test if the week following the current system time falls within the next week, you can use the following expression:

// Output: true
Date.IsInNextWeek( Date.AddWeeks( DateTime.FixedLocalNow(), 1 ) )

Other functions related to Date.IsInNextWeek are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/date-isinnextweek

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy