Date.IsInPreviousDay is a Power Query M function that indicates whether the given date(time) value occurs during the previous day, 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.IsInPreviousDay( dateTime as any ) as nullable logical
Description
Date.IsInPreviousDay determines if a given value (of type date, datetime, or datetimezone) occurs during the previous day, based on the current system date and time. Returns false for values within the current day.
Examples
Let’s explore two straightforward examples to understand how the Date.IsInPreviousDay function works.
Identifying the Previous Day in a Calendar Table
Suppose you have a calendar table and you want to add a column that indicates true
for dates that fall on the previous day. You can do this using the Date.IsInPreviousDay function on your [Date]
column.
Date.IsInPreviousDay( [Date] ) // Output depends on [Date] column
This expression returns true
for any date in the [Date]
column that falls on the previous day.
For example, if today is July 6, 2024, this function will return true
for all rows with dates of July 5, 2024. Here’s a screenshot showing this:
You can see that the previous day, July 5, 2024, is marked with true
.
Using the Current Date and Time
To check if the date and time from the previous day falls within the previous day, you can use the following expression:
// Output: true
Date.IsInPreviousDay( Date.AddDays( DateTime.FixedLocalNow(), -1 ) )
Related functions
Other functions related to Date.IsInPreviousDay are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy