Type.FunctionRequiredParameters
TypeReturns the minimum number of required parameters for a function type.
Syntax
Type.FunctionRequiredParameters(type as type) as numberParameters
| Name | Type | Required | Description |
|---|---|---|---|
type | type | Yes | A function type whose required parameter count is returned. |
Return Value
number — The count of required (non-optional) parameters in the function type.
Remarks
Type.FunctionRequiredParameters returns the number of parameters that must always be provided when calling a function. Optional parameters (declared with the optional keyword) are not counted.
Use Value.Type(fn) to get the function type before passing it to this function.
This is useful for building validation logic, documentation, or dynamic dispatch based on the arity of a function.
Examples
Example 1: Required parameters of a two-argument function
let
FType = type function (x as number, y as number) as number
in
Type.FunctionRequiredParameters(FType)Result
Result | |
|---|---|
| 1 | 2 |
Example 2: Optional parameters are not counted
let
FType = type function (x as number, optional y as nullable number) as number
in
Type.FunctionRequiredParameters(FType)Result
Result | |
|---|---|
| 1 | 1 |
Example 3: Check required parameters of Number.Round
Result
Result | |
|---|---|
| 1 | 1 |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks