define_udf
Define a DAX User-Defined Function in your Power BI model by providing typed parameters, a return type, and a DAX body expression. Automatically bumps compatibility level to 1702+ if lower.
Instructions
Define a DAX User-Defined Function (a net-new model object). The body carries its own typed parameters and return type. params is a comma-separated name:type list (type = Scalar | Table | ColumnRef | MeasureRef | AnyRef | Numeric | String; omit a type for an untyped param). UDFs need compatibility level 1702+, which is auto-bumped if lower. Inspect existing UDFs with list_udfs.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"sessionId": "<sessionId>",
"name": "<name>",
"bodyDax": "<bodyDax>"
},
"name": "define_udf"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | function name, e.g. AddMargin | |
| params | No | comma-separated name:type params, e.g. amount:Scalar, cost:Scalar (optional) | |
| bodyDax | Yes | the function BODY DAX (the expression after =>), e.g. amount * (1 - cost) | |
| sessionId | Yes | ||
| returnType | No | return type: Scalar | Table (optional) | |
| description | No | description (becomes the /// doc comment) |