Power BI DAX measures written, explained and tested in filter context

by fidji Microsoft Copilot English ~626 tokens
Public excerpt Locked
Model prerequisites first (marked date table, star schema, risky bi-directional filters), then base measures before derived ones, the measure itself, filter context explained line by line, ALL vs ALLSELECTED vs REMOVEFILTERS, a test matrix and the performance traps…

About this prompt

Describe the figure you need and paste your model (tables, columns, relationships): get the DAX measure with VAR / RETURN and DIVIDE, a plain-English explanation of what CALCULATE does to the filter context, the reason the total row may not equal the sum of rows, and a test matrix to prove the measure is right. Built for Microsoft Copilot users working alongside Power BI.

Example output

Provided by the author
STEP 1 — Prerequisites Your Date table is not marked: Table tools → Mark as date table → Date[Date]. Without this, SAMEPERIODLASTYEAR can return wrong results when the relationship uses a datetime column. STEP 2 — Measures ```DAX Sales PY = // Sales of the same period one year earlier, following all current filters CALCULATE ( [Total Sales], SAMEPERIODLASTYEAR ( 'Date'[Date] ) ) Sales YoY % = VAR CurrentSales = [Total Sales] VAR PriorSales = [Sales PY] RETURN IF ( NOT ISBLANK ( PriorSales ), DIVIDE ( CurrentSales - PriorSales, PriorSales ) ) ``` Format: 0.0% STEP 3 — Explanation In the cell "March 2025 / North", the visual filters Date to March 2025 and Store to North. CALCULATE replaces only the Date filter with March 2024; the Region and Category filters stay… STEP 4 — Test plan Row "Total": YoY % is not the sum of monthly percentages, it is recomputed on the year — this is correct…

Details

Model
Microsoft Copilot
Prompt language
English
Who it's for
Power BI report builders, finance and operations analysts who are past SUM but stuck on CALCULATE
Length
~626 tokens (estimate)
Delivered as
Prompt text, shown online after purchase

Reviews

Buyers only

No reviews yet. Only buyers of this prompt can leave one.

Report this prompt