Power BI and DAX

DAX just changed for good: what are User-Defined Functions and why you'll want to use them

Learn how User-Defined Functions make DAX more reusable, organized, and ready for collaborative semantic models in Power BI.

Published article

Renan Brognoli

2026-06-165 minPower BI

If you've been working with Power BI for a while, you know DAX has one particularly annoying trait: you write the same logic ten times across different measures and pray you didn't make a mistake in at least nine of them.

With the June 2026 update, Microsoft finalized the general availability of User-Defined Functions (UDFs) in DAX. The feature had been in preview since September 2025 and now ships complete: support in Power BI Desktop, the web service, and integration with tools like SSMS and Git.

The promise is straightforward. You define a function once. You use it anywhere in the model.

The problem UDFs solve

Imagine you need to calculate a tax-inclusive value in several places across your semantic model. The logic is always the same: a value multiplied by a rate. Simple enough.

The problem starts when the rate changes. You'll need to update every measure, every calculated column, every visual calculation that used that formula. If you're lucky, you remember them all. If not, your report will show inconsistent numbers.

UDFs put an end to that story. You centralize the logic in one place. When the rule changes, it changes in one spot.

How it works in practice

The syntax introduces a new keyword: FUNCTION. The basic structure looks like this:

dax
DEFINE
    FUNCTION FunctionName = ( parameter : TYPE ) => expression

A concrete example: a function that adds tax to a value.

dax
DEFINE
    /// AddTax takes an amount and returns the total including tax
    /// @param {NUMERIC} amount - Pre-tax value
    /// @param {NUMERIC} [taxRate] - Optional tax rate, defaults to 10%
    /// @returns Total value with tax applied
    FUNCTION AddTax = 
        ( amount : NUMERIC, taxRate : NUMERIC = 0.1 ) =>
            amount * ( 1 + taxRate )

EVALUATE
{ AddTax ( 100 ) }
-- Returns 110

Notice the taxRate parameter with a default value. Optional parameters are one of the new features that shipped with GA. You can call AddTax(100) and the function assumes 10% automatically, or pass AddTax(100, 0.15) when you need 15%.

Where you can use UDFs

Once saved to the model, the function behaves like any native DAX function. You can use it in:

  • Measures
  • Calculated columns
  • Visual calculations
  • Other user-defined functions

That last one is worth noting. You can compose functions. A gross margin function can internally call an adjusted cost function. The model becomes modular.

Where to create and edit functions

Microsoft made three paths available for working with UDFs:

DAX Query View: Where you define, test, and save functions to the model. There's an "Update model with changes" button to commit them permanently. IntelliSense already recognizes defined functions as you type.

TMDL View: For those who prefer working with definition files. UDFs are saved as TMDL files and can be versioned through Git. Great for teams collaborating on the same model.

Model Explorer: Functions show up under a dedicated "Functions" node. You can create, edit, and track dependencies from there.

The Copilot connection

One detail Microsoft emphasized heavily: UDFs are first-class objects in the semantic model. They have typed signatures, descriptions, and documented parameters.

That means AI tools like Copilot can discover and invoke these functions with much greater precision than by trying to infer logic from generic measures. Instead of Copilot guessing how to calculate your margin, you explicitly expose a CalculateMargin function with clear documentation.

For anyone investing in automation and AI within Power BI, this changes things considerably.

Technical requirements

Before you start creating functions, a heads-up: UDFs require a database compatibility level of 1702 or higher. Older models may need updating.

In Power BI Desktop from the June 2026 release onward, the feature is enabled by default. In SSMS, support starts from version 22.5.

Is it worth adopting now?

For new models, the answer is straightforward: yes. Start using UDFs for any logic that repeats. Margins, taxes, currency conversion, business rules. Anything you'd write more than once is a candidate for a function.

For legacy models, the process is more gradual. It's not worth refactoring everything at once. But as you need to adjust existing calculations, it's worth centralizing that logic into functions.

DAX always had power. Now it has organization too.

Sources: Microsoft Power BI June 2026 Feature Summary, official Microsoft Learn documentation (DAX User-Defined Functions Best Practices), Microsoft Fabric Community.