Function.Invoke

Function

Invokes a function with a list of arguments.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Function.Invoke(function as function, args as list) as any

Parameters

NameTypeRequiredDescription
functionfunctionYesThe function to invoke.
argslistYesA list of argument values to pass to the function.

Return Value

anyThe 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
1Text.UpperHELLO 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
1lowerPower Querypower query

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks