A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data.
DateTime.LocalNow() is a dynamic function. It can return a new value each time it is invoked during query evaluation.
In Power Query, steps are defined in a let ... in expression, and later steps reference earlier steps by variable name. In the sample:
let
one = Function.InvokeAfter(()=>DateTime.LocalNow(), #duration(0, 0, 0, 5)),
two = one
in
two
one is the expression that waits 5 seconds and then evaluates DateTime.LocalNow(). two just references one.
The reason the timestamp shown for an earlier step can appear later than the timestamp shown for a later step is that DateTime.LocalNow() is not fixed. When the editor previews steps, Power Query can evaluate expressions at different times, so the value displayed for a step preview is not guaranteed to be the same moment across all step views.
If the same timestamp must remain constant throughout a single query evaluation, use a fixed current-time function instead, such as DateTime.FixedLocalNow(). Fixed variants return the same value throughout one query evaluation.