| name | query-builder-dax |
| description | Guide for the DAX query shape produced by the Query Builder in the DAX test widget. Use this when modifying how the Query Builder generates DAX, or when generating an EVALUATE query from columns, measures, filters and sorting. |
SKILL.md — Query Builder DAX Generation
Purpose
Document the canonical DAX query structure produced by the Query Builder in
the DAX performance test widget (_build_summarize_dax in
src/sempy_labs/semantic_model/_test_dax.py).
The pattern follows the well-known "Using DAX as a Query Language" approach
(Michael Kovalsky, Elegant BI:
https://www.elegantbi.com/post/daxquerylanguage), built on
SUMMARIZECOLUMNS.
Use this skill when changing how Query Builder state (columns, measures,
filters, sorting) is converted to DAX, so the generated query stays valid and
consistent.
The canonical query shape
EVALUATE
SUMMARIZECOLUMNS(
'Geography'[Area],
'Geography'[Country],
'Product'[Product],
FILTER(KEEPFILTERS(VALUES('Product'[Product Category])), 'Product'[Product Category] = "Bicycles"),
"Revenue", [Revenue]
)
ORDER BY 'Geography'[Area], 'Geography'[Country]
SUMMARIZECOLUMNS implies the aggregation (the SQL GROUP BY is not needed)
and the model relationships handle the joins.
Element order (STRICT — wrong order errors out)
Inside SUMMARIZECOLUMNS(...) the elements MUST appear in this order:
| # | Element | Where it goes | Syntax |
|---|
| 1 | Attributes (columns) | First | 'Table'[Column] — one per group-by column, left to right |