DateTime.FixedLocalNow
DateTimeReturns the current local date and time, fixed for the entire query evaluation.
Syntax
DateTime.FixedLocalNow() as datetimeReturn Value
datetime — The local date and time at which query evaluation began.
Remarks
DateTime.FixedLocalNow returns the current local date and time, but unlike DateTime.LocalNow(), it returns a consistent value for the entire duration of query evaluation. Multiple calls to DateTime.FixedLocalNow within a single query always return the same timestamp, making it suitable for calculations that require a stable reference point such as age calculations or elapsed-time computations across multiple columns.
DateTime.LocalNow() may return different values when called at different points during a long-running query, causing slight inconsistencies in computed columns that both reference "now". DateTime.FixedLocalNow() is guaranteed to be the same for every row in a transformation, eliminating this risk. Prefer it over DateTime.LocalNow() whenever you need a stable snapshot of the current time.
Note that in Power BI Service and Dataflows, the "local" time reflects the cloud region's system time (typically UTC) rather than your local machine's timezone. For cloud-hosted refreshes, consider using DateTimeZone.FixedUtcNow() instead for clarity and consistency.
Examples
Example 1: Calculate consistent elapsed time across multiple columns
let
Now = DateTime.FixedLocalNow(),
Source = Table.SelectColumns(
Table.SelectRows(OrderLog, each [DurationMinutes] <> null),
{"LogID", "Timestamp"}
),
WithDays = Table.AddColumn(Source, "DaysOld",
each Duration.TotalDays(Now - [Timestamp]), type number),
WithHours = Table.AddColumn(WithDays, "HoursOld",
each Duration.TotalHours(Now - [Timestamp]), type number)
in
WithHoursThe final output — adds HoursOld from the same fixed reference, so DaysOld × 24 and HoursOld always agree.
LogID | Timestamp | DaysOld | HoursOld | |
|---|---|---|---|---|
| 1 | L002 | 1/16/2024 2:15:00 PM | 781.80 | 18,763.80 |
| 2 | L004 | 1/20/2024 8:45:00 AM | 778.10 | 18,673.30 |
| 3 | L006 | 2/2/2024 10:05:00 AM | 765 | 18,359.90 |
| 4 | L008 | 2/12/2024 9:30:00 AM | 755 | 18,120.50 |
Example 2: Stamp rows with a consistent refresh timestamp
let
RefreshTime = DateTime.FixedLocalNow(),
Source = Table.SelectColumns(Table.FirstN(Sales, 4), {"OrderID", "OrderDate"})
in
Table.AddColumn(Source, "AsOf", each RefreshTime, type datetime)The final output — adds an AsOf column to Source containing the fixed RefreshTime value on every row.
OrderID | OrderDate | AsOf | |
|---|---|---|---|
| 1 | 1 | 1/15/2024 | 3/8/2026 10:00:00 AM |
| 2 | 2 | 1/18/2024 | 3/8/2026 10:00:00 AM |
| 3 | 3 | 2/1/2024 | 3/8/2026 10:00:00 AM |
| 4 | 4 | 2/10/2024 | 3/8/2026 10:00:00 AM |
Example 3: Filter orders from the current day using a fixed reference
let
Today = Date.From(DateTime.FixedLocalNow())
in
Table.SelectRows(Sales, each [OrderDate] = Today)The final output — Table.SelectRows keeps Sales rows whose OrderDate equals Today; every sample order is from 2024, so the result is an empty table with the Sales columns.
OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region |
|---|