dax-authoring
Skill646 starsChanged 56 days agoMITView on GitHub
Write and test DAX queries against Power BI semantic models. Covers DAX syntax rules, query patterns, time intelligence, and an iterative test workflow using `npx rayfin connector invoke`.
12 other projects use a version of this, 10 of them edited.
Adopted by
Most recently taken up by
- microsoft/ignite26-PREL40word for word, first seen Nov 22, 2026
- microsoft/ignite26-LAB690their own version, first seen Nov 22, 2026
- microsoft/fabric-apps-analytic-templatesedited, first seen Nov 16, 2026
- microsoft/awesome-rayfinedited, first seen Nov 15, 2026
- microsoft/DataHub-App-for-Microsoft-Copilot-Agents-Cowork-and-Autopilotsedited, first seen Nov 8, 2026
- microsoft/ValueLens-for-Microsoft-Copilotedited, first seen Oct 25, 2026
Other versions12 projects use a version of this.
Word for word · 1
- microsoft/ignite26-PREL40★ 3100% same
Edited · 10
- microsoft/awesome-rayfin★ 11685% same
- microsoft/ConsumptionCentral-for-Microsoft-Copilot★ 3685% same
- microsoft/fabric-apps-analytic-templates★ 3144% same
- microsoft/ValueLens-for-Microsoft-Copilot★ 2385% same
- microsoft/AnalyticsHub-Dashboard★ 1685% same
- microsoft/DataHub-App-for-Microsoft-Copilot-Agents-Cowork-and-Autopilots★ 1685% same
- microsoft/aitour27-LTG291-turn-your-data-into-production-apps-with-rayfin★ 385% same
- microsoft/frontiertour27-LTG291-turn-your-data-into-production-apps-with-rayfin★ 385% same
- microsoft/aitour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabric★ 185% same
- microsoft/frontiertour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabric★ 185% same
Wrote their own version · 1
- microsoft/ignite26-LAB690★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository76 other files it gives its agents.
- common/config/typedoc/AGENTS.mdAGENTS.md
- docs/site/AGENTS.mdAGENTS.md
- .github/skills/react-best-practices/AGENTS.mdAGENTS.md
- packages/docgen/AGENTS.mdAGENTS.md
- packages/guide/AGENTS.mdAGENTS.md
- packages/host-docs/AGENTS.mdAGENTS.md
- packages/tools/AGENTS.mdAGENTS.md
- packages/tools/cli/AGENTS.mdAGENTS.md
- packages/tools/cli/assets/agent-files/AGENTS.mdAGENTS.md
- packages/tools/common/AGENTS.mdAGENTS.md
- packages/tools/docs-lib/AGENTS.mdAGENTS.md
- packages/tools/mcp/AGENTS.mdAGENTS.md
- packages/tools/vscode/AGENTS.mdAGENTS.md
- packages/typescript-sdk/AGENTS.mdAGENTS.md
- packages/typescript-sdk/auth/AGENTS.mdAGENTS.md
- packages/typescript-sdk/core/AGENTS.mdAGENTS.md
- packages/typescript-sdk/data/AGENTS.mdAGENTS.md
- packages/typescript-sdk/storage/AGENTS.mdAGENTS.md
- packages/udf/udf-worker-extension/AGENTS.mdAGENTS.md
- samples/data-app/AGENTS.mdAGENTS.md
- samples/getting-started-auth/AGENTS.mdAGENTS.md
- samples/notes-app/AGENTS.mdAGENTS.md
- samples/todo-app/AGENTS.mdAGENTS.md
- samples/universal-app/template/AGENTS.mdAGENTS.md
- samples/welcome-app-react-auth/AGENTS.mdAGENTS.md
- samples/welcome-app-react-no-auth/AGENTS.mdAGENTS.md
- samples/welcome-app-typescript/AGENTS.mdAGENTS.md
- hotfix-releaseSkill
- launch-vscode-extensionSkill
- openspec-apply-changeSkill
- openspec-archive-changeSkill
- openspec-bulk-archive-changeSkill
- openspec-continue-changeSkill
- openspec-exploreSkill
- openspec-ff-changeSkill
- openspec-new-changeSkill
- openspec-onboardSkill
- openspec-sync-specsSkill
- openspec-verify-changeSkill
- privacy-dfdSkill
- rayfin-cli-uxSkill
- vercel-react-best-practicesSkill
- react-clean-architectureSkill
- run-cli-e2e-locallySkill
- vscode-react-webview-architectureSkill
- vscode-webview-trpc-messagingSkill
- rayfin-connectorsSkill
- rayfin-functionsSkill
- rayfinSkill
- rayfin-storageSkill
- rayfin-getting-startedSkill
- app-designSkill
- app-validationSkill
- dax-authoringSkill
- fabric-cliSkill
- fabric-sdkSkill
- playwright-cliSkill
- query-designSkill
- schema-discoverySkill
- visualsSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
11 rules. 6 are common, 0 are distinctive, and 5 are very specific to this project.
6
Common
Most of the 11 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 42
Always test generated DAX via npx rayfin connector invoke <alias> executeQuery --file <query>.query.json before using in app code
- Very specific: line 43
Use fully-qualified 'Table'[Column] for column references
- Very specific: line 44
Use simple [Measure] for measure references
- Common: line 45
Use DEFINE for VAR and local MEASURE declarations (single DEFINE block, no commas)
- Common: line 46
Prefer existing model measures over re-aggregating raw data
- Common: line 70
EVALUATE Statement: Not a function but a statement.
- Very specific: line 71
Use the fully-qualified name 'Table'[Column] for column references, and the simple name [Measure] for measure references.
- Common: line 74
Do not use SUMMARIZECOLUMNS when there is no aggregation and the groupby columns belong to more than one table.
- Common: line 75
When using SELECTCOLUMNS or CALCULATETABLE, include any columns needed downstream (ORDER BY, FILTER).
- Common: line 138
If error: consult dax-core-reference.md, fix, and re-test
- Very specific: line 155
Prefer the field over TOPN when you want a guard rather than a deliberately ranked subset: exceeding it fails the query with an overflow …
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
DAX Authoring
Table of Contents
| Task | Reference | Notes |
| Must/Prefer/Avoid | SKILL.md: Must/Prefer/Avoid | Guardrails for DAX query generation |
| Generating DAX Queries | SKILL.md: Generating DAX Queries | Core rules, inline examples, EVALUATE/DEFINE patterns |
| DAX Query Structure & Syntax | dax-query-patterns.md: Query Structure | DEFINE / EVALUATE / ORDER BY / START AT |
| DAX Query Key Components | dax-query-patterns.md: Key Components | DEFINE VAR, DEFINE MEASURE, table expressions |
| DAX Query Worked Examples | dax-query-patterns.md: Common Patterns | 11 annotated examples from simple aggregation to cross-table joins |
| DAX Query Anti-Patterns | dax-query-patterns.md: Anti-Patterns | What to avoid in DAX queries |
| CALCULATE & CALCULATETABLE | dax-core-reference.md: CALCULATE & CALCULATETABLE | Context transition, filter types, boolean restrictions, common patterns |
| SUMMARIZECOLUMNS | dax-core-reference.md: SUMMARIZECOLUMNS | Argument order, auto-blank elimination, filter args, vs SUMMARIZE |
| ALL & ALLEXCEPT | dax-core-reference.md: ALL & ALLEXCEPT | CALCULATE modifier vs table function; percentage patterns |
| TREATAS | dax-core-reference.md: TREATAS | Virtual relationships, multi-column filtering |
| DAX Syntax Rules | dax-core-reference.md: DAX Syntax Rules | EVALUATE, CALCULATE, naming, SQL keywords, DEFINE rules |
| Common Mistakes | dax-core-reference.md: Common Mistakes | Variable naming, quoting, escaping, scalar EVALUATE, multi-table SUMMARIZECOLUMNS |
| BLANK Semantics | dax-core-reference.md: BLANK Semantics | BLANK vs NULL, propagation, equality, ISBLANK, DIVIDE, non-empty semantics |
| Time Intelligence Patterns | SKILL.md: Time Intelligence | When to consult TI reference |
| Date Table Prerequisites | dax-time-intelligence.md: Prerequisites | Date table requirements, mark as date table |
| YTD / QTD / MTD | dax-time-intelligence.md: Period-to-Date | TOTALYTD, DATESYTD, DATESINPERIOD patterns |
| Year-over-Year / Period Comparisons | dax-time-intelligence.md: Period Comparisons | SAMEPERIODLASTYEAR, DATEADD, PARALLELPERIOD |
| Rolling Windows | dax-time-intelligence.md: Rolling Windows | DATESINPERIOD rolling 12-month patterns |
| Opening/Closing Balances | dax-time-intelligence.md: Balances | Semi-additive measures, LASTDATE, LASTNONBLANK |
| TI in DAX Queries (Critical Rules) | dax-time-intelligence.md: Critical Rules for TI in Queries | CALCULATETABLE + TREATAS pattern for query context |
| TI Common Mistakes | dax-time-intelligence.md: Common Mistakes | Missing date table, wrong granularity, fiscal calendar |
| Testing & Iteration | SKILL.md: Testing & Iteration | Execute → inspect → fix → re-test workflow |
Must / Prefer / Avoid
Must
- Always test generated DAX via
npx rayfin connector invoke <alias> executeQuery --file <query>.query.jsonbefore using in app code - Use fully-qualified
'Table'[Column]for column references - Use simple
[Measure]for measure references - Use DEFINE for VAR and local MEASURE declarations (single DEFINE block, no commas)
- Prefer existing model measures over re-aggregating raw data
- Wrap currency and decimal measures in
CONVERT([Measure], DOUBLE). A fixed-decimal measure can come back as a scaled integer, so a total of2,613,203.85renders as26,132,038,531— a plausible-looking number that is wrong by four orders of magnitude, on a dashboard nobody will double-check. This has now shipped twice. Compare what the CLI returns against what the app shows; if they differ by a power of ten, this is why.
Prefer
- SUMMARIZECOLUMNS as the primary grouping function for queries
- TREATAS for filter arguments in SUMMARIZECOLUMNS
- Variables (VAR) to improve readability and avoid repeated calculations
Avoid
- SQL keywords (SELECT, WHERE, HAVING, etc.) within DAX expressions
- EVALUATE with scalar functions directly (wrap in ROW or table function)
Generating DAX Queries
DAX Syntax Rules
- Measures are named objects in the semantic model. They specify how to aggregate data. Measures should be used first to answer user requests before a new DAX formula is used to aggregate data.
- EVALUATE Statement: Not a function but a statement. It must always precede a table expression. Avoid pairing EVALUATE with scalar functions like CONCATENATEX, SUMX, DISTINCTCOUNT, etc.
- Use the fully-qualified name
'Table'[Column]for column references, and the simple name[Measure]for measure references. - CALCULATE takes a scalar expression as its first argument. CALCULATETABLE takes a table expression as its first argument.
- SUMMARIZECOLUMNS requires a specific order: groupby columns, then filters, then aggregations/measures.
- Do not use SUMMARIZECOLUMNS when there is no aggregation and the groupby columns belong to more than one table; use VALUES, SUMMARIZE, or SELECTCOLUMNS instead.
- When using SELECTCOLUMNS or CALCULATETABLE, include any columns needed downstream (ORDER BY, FILTER).
- Filters propagate across relationships based on unidirectional or bidirectional settings.
- INTERSECT, UNION, EXCEPT require identical column counts in both inputs.
- For current date/time, use TODAY() or NOW().
Inline Examples
Simple filtered aggregation:
// Total sales for red products
EVALUATE
ROW("Total Sales Amount", CALCULATE([Total Amount], 'Product'[Color] == "Red"))Multi-filter grouping with SUMMARIZECOLUMNS:
DEFINE
VAR _Filter1 = TREATAS({"Consumer Electronics"}, 'Product'[Category])
VAR _Filter2 = FILTER(ALL('Calendar'[Year]), 'Calendar'[Year] >= 2022 && 'Calendar'[Year] <= 2023)
EVALUATE
SUMMARIZECOLUMNS(
'Calendar'[Year],
'Calendar'[Month],
_Filter1,
_Filter2,
"Total Quantity", SUM('Sales'[Order Quantity]),
"Discount", [Total Discount]
)TopN with filtering:
DEFINE
VAR _Filter = TREATAS({"Red", "Black"}, 'Product'[Color])
VAR _Core = SUMMARIZECOLUMNS('Product'[Name], _Filter, "Total Sales", [Total Amount])
EVALUATE
TOPN(10, _Core, [Total Sales], DESC)For full syntax reference, worked examples, and anti-patterns, see dax-query-patterns.md. For function details, see dax-core-reference.md.
Time Intelligence
Time intelligence functions enable period-based analysis (YTD, YoY, rolling windows, etc.). They require a properly configured Date table.
Consult dax-time-intelligence.md whenever the user's request involves:
- Period-to-date calculations (YTD, QTD, MTD)
- Period comparisons (Year-over-Year, Month-over-Month)
- Rolling windows (last 12 months, last 30 days)
- Opening/closing balances
- Custom date ranges
Testing & Iteration
- Generate the DAX query expression
- Execute via
npx rayfin connector invoke <alias> executeQuery --file <query>.query.json - Inspect results: check column names, data types, row counts, and actual data values
- If error: consult dax-core-reference.md, fix, and re-test
- Iterate until the query returns expected results
Query Execution
Use npx rayfin connector invoke <alias> executeQuery --file <query>.query.json to run queries. This uses the same SDK pipeline as the running app, so results are identical to what the app produces at runtime. --file takes the operation's JSON input envelope — {"query":"EVALUATE …"} — not a bare .dax file, which is JSON.parsed and fails. Prefer it over --input for anything non-trivial: DAX is full of quotes and brackets that a shell reads as syntax. For full CLI options, see npx rayfin connector invoke --help.
There is no row cap. A query with no resultSetRowCountLimit returns every
row it matches, on the CLI and in the app alike, so an unbounded EVALUATE over
a large table is a real hazard rather than a truncated preview. Bound it
yourself — either in the DAX with an aggregation or TOPN(...), or by adding the
field to the input envelope:
{ "query": "EVALUATE Sales", "resultSetRowCountLimit": 500 }Prefer the field over TOPN when you want a guard rather than a deliberately
ranked subset: exceeding it fails the query with an overflow error, so a
bound that was too tight announces itself, where TOPN returns a
complete-looking partial answer. A value that is not a positive integer is
dropped silently and the query runs unbounded.
Troubleshooting
| Problem | Solution |
connector invoke fails with "not signed in" | Run npx rayfin login |
connector invoke fails with "alias not found" | Run npx rayfin connector list to check available aliases, then npx rayfin connector add --type fabric-semanticmodel to register |
| DAX syntax errors | Consult dax-core-reference.md — check reserved keywords, quoting rules, EVALUATE/scalar mistakes |
| Unexpected query results | Check filter context, relationship direction, BLANK handling in dax-core-reference.md |
| Time intelligence returns wrong values | Check date table prerequisites and critical rules in dax-time-intelligence.md |
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

