Skip to main content
Glama

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.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesfunction name, e.g. AddMargin
paramsNocomma-separated name:type params, e.g. amount:Scalar, cost:Scalar (optional)
bodyDaxYesthe function BODY DAX (the expression after =>), e.g. amount * (1 - cost)
sessionIdYes
returnTypeNoreturn type: Scalar | Table (optional)
descriptionNodescription (becomes the /// doc comment)
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It discloses an important side effect (compatibility level auto-bump to 1702+) and clarifies that the object is net-new. However, it does not mention permissions, reversibility, return values, or error conditions, leaving significant behavioral aspects undisclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is five sentences, all relevant and information-dense. It front-loads the purpose and immediately provides the key parameter format and compatibility detail, with no wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the essential aspects of a complex creation tool: purpose, parameter syntax, compatibility side effect, and how to inspect existing UDFs. It omits details about return values or session handling, but given the complexity, it is largely complete for invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 83%, so the baseline is 3. The description adds meaningful semantics beyond the schema by detailing the params format (comma-separated name:type list with enumerated types and optional type) and clarifying that bodyDax is the expression after =>, which helps correctly construct the UDF.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the verb 'Define' and the resource 'DAX User-Defined Function', noting it is a net-new model object. This distinguishes it from sibling tools like add_measure or set_shared_expression, which target different object types.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides context on when to use this tool (defining a UDF) and explicitly mentions inspecting existing UDFs with list_udfs as an alternative for inspection. It also notes compatibility level auto-bump, but doesn't explicitly exclude other creation tools like add_measure.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyphonica/powerbi-pbix-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server