dax-standard

Write readable, debuggable DAX measures using a table-first pattern with VARs and X-aggregators.

6|3|Updated Jul 4, 2026
One-click install
npx skills add https://github.com/InsightfulAnalytics/PBI_Agentic_Dev --skill dax-standard-insightfulanalytics
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dax-standard
Source: https://github.com/InsightfulAnalytics/PBI_Agentic_Dev/tree/main/plugins/semantic-models/skills/dax-standard
Command: npx skills add https://github.com/InsightfulAnalytics/PBI_Agentic_Dev --skill dax-standard-insightfulanalytics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? DAX measures written as nested CALCULATE expressions are hard to read, impossible to step through, and silently wrong when filter arguments replace the user's selections. This Skill enforces a house style where every measure builds the rows it needs into a table variable and aggregates over it, so each step can be inspected independently. ## Core Features & Use Cases - Table-first measure authoring: Compose measures as scalar VARs, a FILTER-built table variable, and an X-aggregator, with a named __Result returned at the end. - Step-3 decision rules: Choose between X-aggregators and CALCULATE based on whether the expression is an existing measure, a non-additive aggregation, or a row-level computation, with KEEPFILTERS guidance. - Dynamic format strings and UDFs: Format numbers with formatStringDefinition and DAX user-defined functions instead of FORMAT(), which returns text and breaks sorting and aggregation. - Debugging by swapping RETURN: Inspect any intermediate step with RETURN COUNTROWS(__Table) or TOCSV(__Table), something nested CALCULATE cannot do. - Use Case: When asked to write a year-over-year sales measure, produce CALCULATE([Total Sales], DATEADD(DimDate[Date], -1, YEAR)) per the time-intelligence exception, while building a customer retention measure as EXCEPT/INTERSECT over period-key tables. ## Quick Start Ask the agent to write a DAX measure for a specific KPI such as on-time delivery percentage and have it follow the table-first house style.

Frequently Asked Questions about dax-standard

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

FAQPage Schema
How do I write a readable DAX measure in Power BI?▼

Build the measure in three steps: capture scalars from context in VARs, filter a table down to the rows the calculation needs, then aggregate over it with an X-function like SUMX. Name the final variable __Result and return it, so any intermediate step can be inspected by swapping the RETURN.

When should I use CALCULATE instead of FILTER and SUMX in DAX?▼

Use CALCULATE for time intelligence over a proper date table, when aggregating an existing measure, or for non-additive aggregations like DISTINCTCOUNT and ratios. Keep FILTER plus X-aggregators for computed columns and row-level expressions, which cannot move into CALCULATE.

Why does SUMX over a measure give wrong results for ratios?▼

SUMX forces context transition per row and then adds the results, so a ratio like 30.9% plus 29.1% becomes a meaningless 59.9%. Use CALCULATE([Measure], __Table) instead, which evaluates the measure once over the pooled set.

How do I debug a DAX measure step by step?▼

Temporarily change the RETURN statement to inspect any intermediate variable, such as RETURN COUNTROWS(__Table) to check row counts or RETURN TOCSV(__Table) to view the table's rows in a visual. EVALUATEANDLOG does the same at scale in DAX query view.

Why should I avoid FORMAT() for number formatting in DAX measures?▼

FORMAT returns text, so the measure stops being numeric and charts, sorting, and aggregation break. Use a dynamic format string via formatStringDefinition with a user-defined function like Fmt.Scaled, and never combine formatString with formatStringDefinition on one measure.

When should I use the DAX optimization skill instead of this one?▼

Use the optimization skill only when a measure is measurably slow or you are reading server timings and query plans. Author new measures table-first for readability, and switch to CALCULATE-based optimization patterns only when profiling proves a specific measure needs it.