User-defined functions (UDF)


A DAX user-defined function (UDF) is a named, reusable expression declared with the DEFINE FUNCTION statement. UDFs are not subroutines invoked on a call stack; they expand inline at the call site as macros. The function body is substituted wherever the function is called, which means that expressions only valid in certain positions (such as CALCULATE modifiers) can be encapsulated inside a function and remain valid after expansion.

UDFs can be defined at query level inside a DEFINE block or stored in a semantic model and shared across all measures and calculated columns in that model.

Related SQLBI articles:

Content in this section:

Last update: Jun 06, 2026