query-design
Skill10 starsChanged 32 days agoMITView on GitHub
Separates DAX data-fetching from TypeScript presentation. Guides when to use DAX vs. TypeScript vs. Vega-Lite for aggregation, total rows, FORMAT(), SELECTCOLUMNS, BLANK handling, filtering, multi-grain queries, cross-filtering and cross-highlight subset/overlay queries, and format strings.
9 other projects use a version of this, 6 of them edited.
Adopted by
Most recently taken up by
- microsoft/DataHub-App-for-Microsoft-Copilot-Agents-Cowork-and-Autopilotsword for word, first seen Nov 8, 2026
- microsoft/fabric-apps-analytic-templatesedited, first seen Nov 3, 2026
- microsoft/ValueLens-for-Microsoft-Copilotword for word, first seen Oct 25, 2026
- microsoft/ConsumptionCentral-for-Microsoft-Copilotword for word, first seen Oct 25, 2026
- microsoft/frontiertour27-LTG291-turn-your-data-into-production-apps-with-rayfinedited, first seen Oct 17, 2026
- microsoft/frontiertour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabricedited, first seen Oct 17, 2026
Used with
Projects with it also use rayfin-functions.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
MicrosoftSkillrayfin-functions
Use when writing Rayfin user-defined functions (UDFs), invoking functions from frontend code, or using functions CLI commands. Triggers: rayfin functions, udf.func, UserDataFunctions, RayfinContext, FabricContext, AppFunctionsSchema, functions init, dev functions apply, client.functions, invoke, func start, function_app.ts, types.ts, rayfin/functions/, FunctionClient, FunctionsSchema, fabric-user-data-functions, functionsBaseUrl, VITE_RAYFIN_FUNCTIONS_URL, bootstrap.ts, rayfinClient.ts
Also in 3 projects that use this
Other versions9 projects use a version of this.
Word for word · 3
Edited · 6
- microsoft/rayfin★ 64676% same
- microsoft/fabric-apps-analytic-templates★ 2990% same
- microsoft/aitour27-LTG291-turn-your-data-into-production-apps-with-rayfin★ 298% same
- microsoft/frontiertour27-LTG291-turn-your-data-into-production-apps-with-rayfin★ 298% same
- microsoft/aitour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabric★ 198% same
- microsoft/frontiertour27-BRK390-building-ai-applications-with-microsoft-databases-and-fabric★ 198% same
Wrote their own version · 0
None found.
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 repository9 other files it gives its agents.
- app/AGENTS.mdAGENTS.md
- app-designSkill
- app-validationSkill
- dax-authoringSkill
- fabric-cliSkill
- fabric-sdkSkill
- playwright-cliSkill
- schema-discoverySkill
- visualsSkill
The file
We split this skill into the rules it gives an agent
1 rule. 1 is common, 0 are distinctive, and 0 are very specific to this project.
1
Common
Most of the 6 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 106
Read these when working on a specific topic:
“Common” is measured: kept by at least 6 in 10 of the 6 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
Query Design — Separation of Data and Presentation
DAX computes and fetches data. TypeScript shapes it for display. VegaVisual and DataGrid render it.
Aggregate in DAX to the visual's grain — never fetch lower-grain rows to roll up client-side. When a visual layout changes, only the TypeScript or spec layer should change — not the DAX query.
Responsibility Matrix
| Concern | Owner |
| Semantic measures (SUM, DISTINCTCOUNT, etc.) | DAX |
| Filters and slicers | DAX or TypeScript (see Filter Strategy) |
| Grouping grain (SUMMARIZECOLUMNS) | DAX |
| Time intelligence (YTD, YoY) | DAX |
| TopN / payload reduction | DAX |
| Deterministic row ordering (ORDER BY) | DAX (for debugging — not presentation sort) |
| Partitioning a flagged result table | TypeScript |
| Coordinating separate query results | TypeScript (one hook call per result table) |
| Server-provided grand totals (preferred, supports all aggregation types) | DAX + TypeScript row partitioning |
| DataGrid-computed grand totals | DataGrid (alternative only for additive sum values or a count of fetched leaf rows) |
| Filling dimension gaps | TypeScript (stitch dimension list into sparse results) |
| Reshaping (pivot, unpivot) | TypeScript |
| Column display names | columnMetadata in factory file |
| Vega-Lite / DataGrid field identifiers | columnMetadata.name (bracket-free alias) |
| Number/date formatting | columnMetadata.format / Vega-Lite spec |
| User-facing sort order | TypeScript / Vega-Lite sort / DataGrid sort |
| Decorative labels, icons | DataGrid cellRenderer or Vega-Lite condition |
| Axis titles, legends, color encoding | Vega-Lite spec |
Rules
Must
- Aggregate in DAX to the visual's grain — never fetch lower-grain rows just to roll them up to that grain in TypeScript
- One
EVALUATEper.daxfile; useROLLUPADDISSUBTOTALwhen DataGrid body and grand-total grains share one result table ORDER BYin DAX for stable, diffable results — not presentation sort- Same filters/measures across related split-grain queries to prevent drift
Prefer
SUMMARIZECOLUMNSfor grouped aggregation — it also drops BLANK-measure rows, keeping payloads small- DAX's natural column names (
'Table'[Column],[Measure]) ascolumnMetadatakeys, mapped to a bracket-freenameand a human-readabledisplayName - Raw typed values from DAX — format via
columnMetadata.formator Vega-Lite, neverFORMAT() - Model-defined format strings (from
INFO.VIEW.MEASURES()) over invented ones - Multiple lightweight queries for independently shaped datasets; one flagged rollup query for a DataGrid body and grand total
- User-facing sort in TypeScript / Vega-Lite / DataGrid — never re-query for sort
Avoid
SELECTCOLUMNSsolely for renaming — usecolumnMetadata(name+displayName) instead- Reusing the raw DAX column name as
columnMetadata.name—[].make the visual readundefined UNIONto mix body and total grains — useROLLUPADDISSUBTOTALand partition its flagged rowsFORMAT()in DAX — converts to text, breaks sorting and charting- Converting BLANK to
0/""/"N/A"in DAX — causes result-set explosion CONCATENATEX,UNICHAR, emoji prefixes — decorative text belongs incellRendereror Vega-Lite- Fetching all members of high-cardinality dimensions just to fill gaps
Decision Flowchart
Need to add something to the query result?
|-- Calculation / aggregation / filter?
| -> DAX (measures, CALCULATE, SUMMARIZECOLUMNS)
|-- Interactive filter the user controls?
| -> Low-cardinality: widen grain, filter in TypeScript or Vega-Lite transform
| -> High-cardinality: push filter to DAX, re-query
|-- Adding a DataGrid grand total?
| -> DAX rollup query: split body and total rows with toRollupDataTables
| and always pass the returned grandTotalTable via grandTotals.data
| -> DataGrid-computed sum/count: pass grandTotals without data and set defaultAggregation
|-- Merging datasets or adding other synthetic rows?
| -> Charts: pass multiple DataTables to VegaVisual, layer in spec
| -> Grids: append rows in TypeScript, style via cellRenderer
|-- Renaming a column for display?
| -> columnMetadata in the factory file (displayName)
|-- Formatting, labeling, or encoding?
| -> Vega-Lite spec or DataGrid cellRenderer
|-- Decorating values (icons, status badges, null placeholders)?
| -> DataGrid cellRenderer or Vega-Lite condition encoding
|-- Not sure?
-> Does it change what the data *means* (filter, measure, grain)? -> DAX
Does it change only how data is *rendered* (labels, icons, layout)? -> TypeScript / Vega-Lite spec / DataGrid cellRenderer
Still unclear? -> Read the relevant reference aboveInteractivity
Reports coordinate multiple visuals: a selection in one changes what the others show. Two distinct behaviors, with different data work behind them:
- Cross-filtering — a selection in one visual constrains the data shown in another, removing or narrowing the non-matching rows from the target's view. The target shows less. Applying that constraint is a cost/cardinality tradeoff — widen the grain and filter client-side, or push the filter into DAX and re-query. See Filter strategy.
- Cross-highlighting — a selection in one visual emphasizes the matching subset within another while the full context stays visible. The target keeps its baseline (dimmed) and draws the selected subset bright on top. The subset is a separate aggregation aligned to the baseline's grouping, measures, and row set — not a client-side filter of the baseline. See Highlight queries.
Both consume the predicate-based selection events the visual components emit (onInteraction). The components render only the DataTables they are handed; this skill produces those tables. For how a spec binds and layers multiple datasets, see the visuals skill's multi-data input reference.
Reference Materials
Read these when working on a specific topic:
- Anti-patterns and corrections — Open when reviewing a query that uses
UNIONfor totals,FORMAT(),SELECTCOLUMNSfor renaming,CONCATENATEX/emoji decoration, BLANK-to-0conversion, orGENERATE/CROSSJOINfor gap-filling. - Multi-grain patterns — Open when a single visualization needs data at multiple grains (e.g., bars + reference line, region detail + total row, monthly trend + YTD), to choose between one flagged rollup result and separate queries while keeping related factories, hooks, and
DataTables aligned. - Filter strategy — Open when adding a user-controlled filter or implementing cross-filtering, and deciding whether to widen the grain (filter client-side) or push the filter into DAX (re-query on each change).
- Highlight queries — Open when writing the "selected subset" overlay query for a cross-highlight visual: an aligned
CALCULATETABLE/TREATASquery whose rows match the baseline. - Format strings — Open when picking a
columnMetadata.formatvalue, when a measure has a dynamic format string, or when formatting needs to flow into a Vega-Lite axis.
Integration with Sibling Skills
- schema-discovery — Schema exploration; discover tables, columns, and relationships before writing queries.
- dax-authoring — DAX syntax, query patterns, and testing workflow. Apply this skill's principles when deciding what DAX should compute.
- visuals — Vega-Lite specs and DataGrid configuration. Push formatting and labels into specs, not DAX.
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.

