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 — the WithHours table showing each log entry's age in both days and hours, computed from a single fixed timestamp.
LogID | Timestamp | DaysOld | HoursOld | |
|---|---|---|---|---|
| 1 | L002 | 1/16/2024 2:15:00 PM | 781.90 | 18,765.70 |
| 2 | L004 | 1/20/2024 8:45:00 AM | 778.10 | 18,675.20 |
| 3 | L006 | 2/2/2024 10:05:00 AM | 765.80 | 18,379.90 |
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)OrderID | CustomerName | Product | Category | UnitPrice | Quantity | OrderDate | Region |
|---|