← ClaudeAtlas

dax-udf-authoringlisted

Use when AUTHORING your own DAX user-defined function — the mechanics of writing a FUNCTION — declaring parameter types (Scalar, AnyRef, ColumnRef, MeasureRef, CalendarRef), VAL vs EXPR evaluation, TABLEOF/NAMEOF, optional parameters and defaults, dot-notation naming, GA limitations and parser red-underline bugs. Not for finding an existing one (that is dax-lib) nor for what a built-in does (that is dax-reference). Triggers on "write a DAX UDF", "define a DAX FUNCTION", "ANYREF", "VAL vs EXPR", "TABLEOF", "optional parameter in a UDF".
CSalcedoDataBI/dax-for-agents · ★ 0 · AI & Automation · score 68
Install: claude install-skill CSalcedoDataBI/dax-for-agents
# DAX UDF Authoring — the mechanics ## Overview How to write a **correct** DAX user-defined function. **Most problems should not be a UDF at all.** Reach for one when the same logic is repeated across measures with only the column or measure reference changing. Do not reach for one to wrap a single measure — see the per-row trap under Common mistakes. For window machinery inside a rolling or trailing UDF, see **`dax-window-functions`**. > **Before writing one from scratch:** search the **`dax-lib`** skill — an index of the > [daxlib.org](https://daxlib.org) registry (55 packages, ~1,649 functions). `TimeSeries.MovingAverage` > (SMA/WMA/EMA over native `WINDOW`) may already solve a rolling-average need. The index tells you > what exists; the code comes from the registry. **Per-function reference:** **`dax-reference`** carries the signature and semantics of each built-in. This skill is about the mechanics of authoring your own, plus the gotchas that bite. ## Syntax — define once, two surfaces ```dax -- DAX Query View (DEFINE) — for testing DEFINE /// Descripción JSDoc (aparece en IntelliSense) /// @param {ANYREF} qtrCol - columna de trimestre fiscal /// @returns promedio de 4 trimestres FUNCTION Contoso.Scorecard.Example = ( qtrCol : ANYREF, metric : ANYREF, N : SCALAR INT64 = 4 ) => <body> ``` ```tmdl -- TMDL view — saves to the model createOrReplace /// Descripción function 'Contoso.Scorecard.Example' = ( qtrCol : ANYREF ) => <body> ```