query-builder-dax

Generates SUMMARIZECOLUMNS-based DAX EVALUATE queries from columns, measures, filters, and sorting.

571|192|Updated May 16, 2024
One-click install
npx skills add https://github.com/microsoft/semantic-link-labs --skill query-builder-dax
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: query-builder-dax
Source: https://github.com/microsoft/semantic-link-labs/tree/main/.claude/skills/query-builder-dax
Command: npx skills add https://github.com/microsoft/semantic-link-labs --skill query-builder-dax

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Converting Query Builder UI state (columns, measures, filters, sorting) into valid DAX queries is error-prone because SUMMARIZECOLUMNS enforces a strict element order and different filter types require different placement. This Skill documents the canonical query shape so generated DAX stays valid and consistent.

Core Features & Use Cases

  • Canonical query structure: Defines the strict element order inside SUMMARIZECOLUMNS — attributes first, then column filters via FILTER(KEEPFILTERS(VALUES(...))), then measures as "Display Name", [Measure] pairs.
  • Filter handling: Maps filter operators (eq, ne, contains, between, blank, etc.) to DAX predicates, and wraps the table in an outer FILTER for measure filters that cannot live inside SUMMARIZECOLUMNS.
  • Sorting and edge cases: Specifies ORDER BY placement after the table expression, legacy fallback behavior, and handling for measures-only queries, empty states, and TOPN wrapping.
  • Use Case: When modifying _build_summarize_dax in src/sempy_labs/semantic_model/_test_dax.py to add a new filter operator, use this Skill to place the predicate correctly and keep the JS serialization and Python helpers in sync.

Quick Start

Generate a DAX EVALUATE query from these columns, measures, filters, and sorting rules using the Query Builder SUMMARIZECOLUMNS pattern.

Frequently Asked Questions about query-builder-dax

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I build a DAX query from columns, measures, and filters?

Use SUMMARIZECOLUMNS with attributes first, then column filters as FILTER(KEEPFILTERS(VALUES('Table'[Column])), predicate), then measures as "Display Name", [Measure] pairs. Add ORDER BY after the table expression for sorting.

How to filter by a measure in a SUMMARIZECOLUMNS DAX query?

Measure filters cannot go inside SUMMARIZECOLUMNS because measures are not yet projected at that point. Wrap the entire SUMMARIZECOLUMNS table in an outer FILTER, such as FILTER(SUMMARIZECOLUMNS(...), [Measure] > 100), combining multiple predicates with &&.

What is the correct element order in SUMMARIZECOLUMNS?

Attributes (group-by columns) come first, followed by column filters, then measures. Sorting is never inside SUMMARIZECOLUMNS; the ORDER BY clause goes after the full table expression. Wrong order causes the query to error out.

Why use KEEPFILTERS with VALUES in DAX column filters?

KEEPFILTERS(VALUES('Table'[Column])) preserves any existing filter context on that column while applying the new predicate. Without KEEPFILTERS, the new filter would override rather than intersect with the surrounding filter context.

Can SUMMARIZECOLUMNS return measures without group-by columns?

Yes, emit SUMMARIZECOLUMNS("Name", [Measure], ...) with no attributes and no ORDER BY. Column filters still apply inside the function and measure filters still wrap the outside. If there are no columns and no measures, return an empty string.