Function.InvokeAfter
FunctionReturns the result of invoking a function after a specified duration delay has passed.
Syntax
Function.InvokeAfter(function as function, delay as duration) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
function | function | Yes | A zero-argument function to invoke after the delay. |
delay | duration | Yes | The duration to wait before invoking the function. |
Return Value
any — The result of invoking the function after the specified delay.
Remarks
Function.InvokeAfter pauses execution for the specified delay duration, then invokes the provided zero-argument function and returns its result. This is useful for introducing deliberate delays into query execution.
### Common use cases
- API rate limiting — adding a delay between paginated API calls to avoid hitting rate limits.
- Retry patterns — waiting before retrying a failed operation.
- Testing and debugging — simulating slow data sources.
The delay parameter is a standard M duration value. For example:
#duration(0, 0, 0, 5)— 5 seconds#duration(0, 0, 1, 0)— 1 minute#duration(0, 0, 0, 0.5)— 500 milliseconds
Note that the delay blocks the query evaluation thread. Use with care in production scenarios, as excessive delays will slow down refresh times.
Examples
Example 1: Invoke a function after a 5-second delay
let
Result = Function.InvokeAfter(
() => DateTime.LocalNow(),
#duration(0, 0, 0, 5)
)
in
#table({"Invoked At"}, {{Result}})Example 2: Simulate rate limiting between API pages
let
DelayedCall = Function.InvokeAfter(
() => "Page loaded after delay",
#duration(0, 0, 0, 1)
)
in
#table({"Result"}, {{DelayedCall}})Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks