Function.Invoke
FunctionInvokes a function with a list of arguments.
Syntax
Function.Invoke(function as function, args as list) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
function | function | Yes | The function to invoke. |
args | list | Yes | A list of argument values to pass to the function. |
Return Value
any — The result of calling the function with the provided arguments.
Remarks
Function.Invoke calls a function by passing its arguments as a list rather than positionally. This is useful when:
- The function to call is stored in a variable or selected dynamically at runtime. - The argument list is constructed programmatically (e.g., from a record or table). - You need to abstract over functions with different arities.
Each element in the args list corresponds to a positional parameter of the function. For optional parameters you want to skip, include null in the corresponding list position.
Examples
Example 1: Invoke Text.Upper dynamically
let
Func = Text.Upper,
Result = Function.Invoke(Func, {"hello world"})
in
#table({"Function", "Result"}, {{"Text.Upper", Result}})Result
Function | Result | |
|---|---|---|
| 1 | Text.Upper | HELLO WORLD |
Example 2: Dynamically choose a function
let
Operation = "lower",
Func = if Operation = "upper" then Text.Upper else Text.Lower,
Result = Function.Invoke(Func, {"Power Query"})
in
#table({"Operation", "Input", "Result"}, {{Operation, "Power Query", Result}})Result
Operation | Input | Result | |
|---|---|---|---|
| 1 | lower | Power Query | power query |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks