Function.ScalarVector

Updated on

Function.ScalarVector is a Power Query M function that returns a scalar function of a specified type that invokes a vector function with a single row of arguments and returns its single output. The function returns the new scalar function.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

Function.ScalarVector(
   scalarFunctionType as type,
   vectorFunction as function,
) as function

Description

Returns a scalar function of type scalarFunctionType that invokes vectorFunction with a single row of arguments and returns its single output. Additionally, when the scalar function is repeatedly applied for each row of a table of inputs, such as in Table.AddColumn, instead vectorFunction will be applied once for all inputs.

vectorFunction will be passed a table whose columns match in name and position the parameters of scalarFunctionType. Each row of this table contains the arguments for one call to the scalar function, with the columns corresponding to the parameters of scalarFunctionType.

vectorFunction must return a list of the same length as the input table, whose item at each position must be the same result as evaluating the scalar function on the input row of the same position.

The input table is expected to be streamed in, so vectorFunction is expected to stream its output as input comes in, only working with one chunk of input at a time. In particular, vectorFunction must not enumerate its input table more than once.

Learn more about Function.ScalarVector in the following articles:

Other functions related to Function.ScalarVector are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/function-scalarvector