DAX Lib Install — bring a published UDF into a real model, attributed
dax-lib finds it. This skill installs it. dax-lib is deliberately an index —
it never carries third-party DAX code (see its own NOTICE). The moment a real
answer is "yes, use this one," the work moves here.
This is not dax-udf-authoring: that skill is for writing your own function from
scratch. This one is for installing someone else's, already-published one — which
means it also owns the paperwork a copy-paste would skip: checking the license,
proving the function runs on this exact model, and leaving a record of where it
came from that survives the function being copied on its own later.
Workflow
Resolve. You need three things from dax-lib's index: packageId, version,
and the exact function name — not the whole package. Install only what is
needed now; a package can ship several functions (TimeSeries.MovingAverage
ships 7 — Simple, Weighted, LinearWeighted, Exponential,
DoubleExponential, Triangular, Geometric) and the rest stay undeployed.
Fetch the real code.
gh api -H "Accept: application/vnd.github.raw" repos/daxlib/daxlib/contents/packages/<first-letter-lowercase>/<packageId-lowercase>/<version>/lib/functions.tmdl
gh api repos/daxlib/daxlib/commits/main --jq .sha # the commit you read it at
Without the Accept header the contents API returns a JSON envelope with the file
base64-encoded, not the TMDL.
Same path convention the repository's scripts/dax-lib/refresh-daxlib.ps1 already reads for the
index — used here to read a function body, not just its name. Pull only the
function '<name>' = ... block requested out of the file; the package's other
functions are not your concern.
Check the license. The daxlib manifest schema has no license field, so there is
no per-package declaration (see dax-lib's NOTICE): the upstream repository carries
a single MIT license naming SQLBI, and reading a contribution as covered by it is a
convention, not a documented agreement. If the package's version directory has its
own LICENSE, record it verbatim. Otherwise the attribution carries
Repo MIT (SQLBI); no per-package license - VERIFY BEFORE SHIPPING, and your final
report to the user repeats that warning unhedged. Do not soften it into a footnote.
Confirm before writing. Check the model's compatibility level (UDFs need 1702 or
later) and run EVALUATE INFO.USERDEFINEDFUNCTIONS(): if a function with that name
already exists, stop and ask — installing would replace it. Then show the user the
function body, the license line and the target model, and install only on a yes.
Install. Prefer a live connection through the modeling MCP
(function_operations → Create) when one is available. Fall back to editing the
model's TMDL on disk — a bare function '<name>' = ... block in the PBIP
definition/ folder; createOrReplace is TMDL view script syntax, not file
syntax — only when nothing live is reachable, and only with Desktop closed on that
model, or its in-memory copy overwrites the edit. Live tooling first, hand-written
TMDL last.
Test. Run one real DAX query against the connected model that calls the
newly installed function and confirms it executes without error. No invented
expected value — the test is "does this run, in this model, on this
compatibility level, against these real column names." A copy-pasted
third-party function is exposed to exactly the same failure modes an
originally-authored one is (a model below the compatibility level DAX UDFs
require fails the same way regardless of who wrote the function).
Report. One message: what was installed (function, package, version,
author), the exact source URL — the version path at the commit SHA from step 2,
not just the package id, the license that
applies (or the no-per-package-license warning), and the result of the test query. No
silent success.
Attribution
The functions.tmdl pulled from daxlib/daxlib already carries two annotations
the registry itself stamps:
annotation DAXLIB_PackageId = TimeSeries.MovingAverage
annotation DAXLIB_PackageVersion = 0.1.1
Keep these as-is — they are the registry's own record. Add the three facts the raw
file does not carry: who wrote it, what license applies, and exactly where it came
from. Attribution lives on the function itself, not in a separate manifest, so
it survives if the function is later exported or copied on its own:
/// Installed from daxlib.org — package TimeSeries.MovingAverage v0.1.1, author Tate Bowman.
/// License: Repo MIT (SQLBI); no per-package license - VERIFY BEFORE SHIPPING.
/// Source: https://github.com/daxlib/daxlib/blob/<sha>/packages/t/timeseries.movingaverage/0.1.1/lib/functions.tmdl
function 'TimeSeries.MovingAverage.Simple' =
( ... )
annotation DAXLIB_PackageId = TimeSeries.MovingAverage
annotation DAXLIB_PackageVersion = 0.1.1
annotation DAXLIB_Author = Tate Bowman
annotation DAXLIB_License = Repo MIT (SQLBI); no per-package license - VERIFY BEFORE SHIPPING
annotation DAXLIB_SourceUrl = https://github.com/daxlib/daxlib/blob/<sha>/packages/t/timeseries.movingaverage/0.1.1/lib/functions.tmdl
If the package's original doc comment exists (the /// line already in its
functions.tmdl, e.g. "Returns a simple moving average..."), keep it as a second
paragraph below the attribution block. The attribution is prepended, never
overwrites the description of what the function does.
What this does not do
- Does not install a whole package — one named function per request.
- Does not resolve dependencies between packages, manage upgrades, or maintain a
lockfile. One named function, one named version, on request.
- Does not decide FOR the user whether a package without its own license is safe to ship. It
installs it, proves it runs, and says so loudly — the shipping decision is
the user's.
- Does not touch
dax-lib's own index or NOTICE. The index stays code-free.
Errors
| Failure |
What to do |
gh api can't reach the package path (renamed, deleted, wrong version) |
Stop, report the exact path tried, do not guess at a substitute |
Requested function name isn't in the fetched functions.tmdl |
Stop, list the functions that are in that file |
| No live model connection and no local TMDL folder to edit |
Stop — this installs into a real target, it does not stage code with nowhere to land |
| Model's compatibility level is below what user-defined functions require |
Report the exact required level; do not silently skip the install |
| Test query errors after install |
Report the raw engine error; do not roll back automatically, but never claim success |
1---2name: dax-lib-install3description: Use when installing a DAX UDF from daxlib.org into a live model or PBIP folder after dax-lib found it. Fetches the function body with gh api, asks before writing, records author, license and source on the function, installs it, and test-runs it. Triggers on "install this UDF", "bring in the daxlib function", "add the daxlib function to my model", "vendor this DAX package".4metadata:5 source: https://skillmd.com/skills/csalcedodatabi/dax-lib-install6---78# DAX Lib Install — bring a published UDF into a real model, attributed910**`dax-lib` finds it. This skill installs it.** `dax-lib` is deliberately an index —11it never carries third-party DAX code (see its own `NOTICE`). The moment a real12answer is "yes, use this one," the work moves here.1314This is not `dax-udf-authoring`: that skill is for writing *your own* function from15scratch. This one is for installing *someone else's*, already-published one — which16means it also owns the paperwork a copy-paste would skip: checking the license,17proving the function runs on this exact model, and leaving a record of where it18came from that survives the function being copied on its own later.1920## Workflow21221. **Resolve.** You need three things from `dax-lib`'s index: `packageId`, `version`,23 and the **exact function name** — not the whole package. Install only what is24 needed now; a package can ship several functions (`TimeSeries.MovingAverage`25 ships 7 — `Simple`, `Weighted`, `LinearWeighted`, `Exponential`,26 `DoubleExponential`, `Triangular`, `Geometric`) and the rest stay undeployed.27282. **Fetch the real code.**29 ```30 gh api -H "Accept: application/vnd.github.raw" repos/daxlib/daxlib/contents/packages/<first-letter-lowercase>/<packageId-lowercase>/<version>/lib/functions.tmdl31 gh api repos/daxlib/daxlib/commits/main --jq .sha # the commit you read it at32 ```33 Without the `Accept` header the contents API returns a JSON envelope with the file34 base64-encoded, not the TMDL.35 Same path convention the repository's `scripts/dax-lib/refresh-daxlib.ps1` already reads for the36 index — used here to read a function *body*, not just its name. Pull only the37 `function '<name>' = ...` block requested out of the file; the package's other38 functions are not your concern.39403. **Check the license.** The daxlib manifest schema has no license field, so there is41 no per-package declaration (see `dax-lib`'s `NOTICE`): the upstream repository carries42 a single MIT license naming SQLBI, and reading a contribution as covered by it is a43 convention, not a documented agreement. If the package's version directory has its44 own `LICENSE`, record it verbatim. Otherwise the attribution carries45 `Repo MIT (SQLBI); no per-package license - VERIFY BEFORE SHIPPING`, and your final46 report to the user repeats that warning unhedged. Do not soften it into a footnote.47484. **Confirm before writing.** Check the model's compatibility level (UDFs need 1702 or49 later) and run `EVALUATE INFO.USERDEFINEDFUNCTIONS()`: if a function with that name50 already exists, stop and ask — installing would replace it. Then show the user the51 function body, the license line and the target model, and install only on a yes.52535. **Install.** Prefer a live connection through the modeling MCP54 (`function_operations` → `Create`) when one is available. Fall back to editing the55 model's TMDL on disk — a bare `function '<name>' = ...` block in the PBIP56 `definition/` folder; `createOrReplace` is TMDL *view* script syntax, not file57 syntax — only when nothing live is reachable, and only with Desktop closed on that58 model, or its in-memory copy overwrites the edit. Live tooling first, hand-written59 TMDL last.60616. **Test.** Run one real DAX query against the connected model that calls the62 newly installed function and confirms it executes without error. No invented63 expected value — the test is "does this run, in this model, on this64 compatibility level, against these real column names." A copy-pasted65 third-party function is exposed to exactly the same failure modes an66 originally-authored one is (a model below the compatibility level DAX UDFs67 require fails the same way regardless of who wrote the function).68697. **Report.** One message: what was installed (function, package, version,70 author), the exact source URL — the version path at the commit SHA from step 2,71 not just the package id, the license that72 applies (or the no-per-package-license warning), and the result of the test query. No73 silent success.7475## Attribution7677The `functions.tmdl` pulled from `daxlib/daxlib` already carries two annotations78the registry itself stamps:7980```tmdl81annotation DAXLIB_PackageId = TimeSeries.MovingAverage82annotation DAXLIB_PackageVersion = 0.1.183```8485Keep these as-is — they are the registry's own record. Add the three facts the raw86file does not carry: who wrote it, what license applies, and exactly where it came87from. Attribution lives **on the function itself**, not in a separate manifest, so88it survives if the function is later exported or copied on its own:8990```tmdl91/// Installed from daxlib.org — package TimeSeries.MovingAverage v0.1.1, author Tate Bowman.92/// License: Repo MIT (SQLBI); no per-package license - VERIFY BEFORE SHIPPING.93/// Source: https://github.com/daxlib/daxlib/blob/<sha>/packages/t/timeseries.movingaverage/0.1.1/lib/functions.tmdl94function 'TimeSeries.MovingAverage.Simple' =95 ( ... )96 annotation DAXLIB_PackageId = TimeSeries.MovingAverage97 annotation DAXLIB_PackageVersion = 0.1.198 annotation DAXLIB_Author = Tate Bowman99 annotation DAXLIB_License = Repo MIT (SQLBI); no per-package license - VERIFY BEFORE SHIPPING100 annotation DAXLIB_SourceUrl = https://github.com/daxlib/daxlib/blob/<sha>/packages/t/timeseries.movingaverage/0.1.1/lib/functions.tmdl101```102103If the package's original doc comment exists (the `///` line already in its104`functions.tmdl`, e.g. *"Returns a simple moving average..."*), keep it as a second105paragraph below the attribution block. The attribution is prepended, never106overwrites the description of what the function does.107108## What this does not do109110- Does not install a whole package — one named function per request.111- Does not resolve dependencies between packages, manage upgrades, or maintain a112 lockfile. One named function, one named version, on request.113- Does not decide FOR the user whether a package without its own license is safe to ship. It114 installs it, proves it runs, and says so loudly — the shipping decision is115 the user's.116- Does not touch `dax-lib`'s own index or `NOTICE`. The index stays code-free.117118## Errors119120| Failure | What to do |121|---|---|122| `gh api` can't reach the package path (renamed, deleted, wrong version) | Stop, report the exact path tried, do not guess at a substitute |123| Requested function name isn't in the fetched `functions.tmdl` | Stop, list the functions that *are* in that file |124| No live model connection and no local TMDL folder to edit | Stop — this installs into a real target, it does not stage code with nowhere to land |125| Model's compatibility level is below what user-defined functions require | Report the exact required level; do not silently skip the install |126| Test query errors after install | Report the raw engine error; do not roll back automatically, but never claim success |