Function.From

Function

Creates a typed function wrapper that converts a unary function to match a specific function type signature.

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

Syntax

Function.From(functionType as type, function as function) as function

Parameters

NameTypeRequiredDescription
functionTypetypeYesThe function type that defines the parameter names and types for the new function.
functionfunctionYesA unary function that receives a record of the named parameters.

Return Value

functionA new function matching the specified type signature that delegates to the provided function.

Remarks

Function.From wraps a unary function (one that takes a single record argument) into a function with a typed multi-parameter signature. The wrapped function receives all named parameters as fields of a record.

This is useful for:

- Creating custom functions with documented parameter names and types that appear in the Power Query UI. - Building reusable function libraries where the parameter metadata is defined separately from the implementation.

The functionType defines the shape of the resulting function (parameter names, types, and return type). The inner function receives a record with field names matching the parameter names.

Examples

Example 1: Create a typed addition function

let
    AddType = type function (a as number, b as number) as number,
    AddFn = Function.From(AddType, (args) => args[a] + args[b]),
    Result = AddFn(10, 32)
in
    #table({"Expression", "Result"}, {{"AddFn(10, 32)", Result}})
Result
Expression
Result
1AddFn(10, 32)42

Compatibility

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