Type.FunctionRequiredParameters is a Power Query M function that determines the minimum number of parameters required to invoke the input function type. The function returns a number indicating the minimum required parameters for the given function type.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Type.FunctionRequiredParameters( type as type ) as number
Description
The Type.FunctionRequiredParameters function is used to identify the minimum number of parameters necessary for invoking a specific function type. The function takes a type value as input and returns a number indicating the number of required parameters. The function accepts both custom types and library functions.
Examples
Let’s say you want to find the required number of parameters for a function like Text.Combine. This function requires 2 parameters and none are optional. The following statement returns the number of required parameters:
// Output: 2
Type.FunctionRequiredParameters( Value.Type( Text.Combine ) )
If you’re dealing with a function that has both required and optional parameters, the function only returns the number of required fields. For example, the Date.FromText function takes 2 arguments, one is required and the other is optional.
// Output: 1
Type.FunctionRequiredParameters( Value.Type( Date.FromText ) )
To return the total number of parameters instead, you can combine the Record.FieldCount and Type.FunctionParameters function:
// Output: 2
Record.FieldCount(
Type.FunctionParameters( Value.Type( Date.FromText ) )
)
Instead of retrieving the type of a library function, you can also provide a custom data type as input. The following statement returns the required number of parameters of such a custom type:
// Output: 1
let
customType = type function ( x as logical, optional y as date) as date,
requiredParameters = Type.FunctionRequiredParameters( customType )
in
requiredParameters
Related functions
Other functions related to Type.FunctionRequiredParameters are:
2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy