Enterprise capstone implementation
Build the model and audit trail
The implementation is a reproducible set of source files, static M and DAX, an independent Python/SQLite oracle and a report blueprint. Open clean-sales.pq in Power Query Advanced Editor as a function; load RawSales with all six columns as text. Invoke CleanSales(RawSales) and expose the Accepted and Rejected record fields as separate queries. Disable load on raw and reject queries. The function validates exact columns, rejects conflicting IDs and parses canonical integer-cent values. Do not deduplicate on key alone.
Define measures and context
Create the six measures in measures.dax separately in the measure bar after building the relationships.
Revenue = DIVIDE(SUM(Sales[RevenueCents]),100)Gross Profit = [Revenue] - [Cost]Gross Margin = DIVIDE([Gross Profit],[Revenue])Cost is defined in the file. Budget Amount guards against any product filter with ISCROSSFILTERED(DimProduct); Budget Variance preserves that blank. Use explicit measures rather than summing displayed margins. Query View scripts in queries.dax are static and native execution is NOT RUN.
Example 1 — reconcile the executive report
With no slicers and all regions visible, Revenue = $440, Cost = $270, Gross Profit = $170 and Gross Margin = 170/440 ≈ 38.64%. Budget is $450 and variance is −$10. January North is $150 revenue, $90 cost, $60 profit, $140 budget and +$10 variance. Use the ratio of sums at the total; equal averaging of the four region/month margin percentages is a different calculation.
Example 2 — verify a zero and an unsupported slice
S6 is an accepted South February line with zero revenue and zero cost; a line-only margin is blank because its denominator is zero. No matching lines are also blank for SUM, but are not a recorded zero. Product A contributes $300 revenue and product B $140; both product rows must display blank budget/variance. Compare the native outputs with verify.py independently rather than assuming SQLite is a DAX engine.
Report design and model boundaries
Executive: revenue, profit, margin and variance cards plus month comparison. Detail: line table, product selection and region drillthrough. Finance: month/region matrix with costs and gross margin; no claim of full financial statements. Add labels, explicit USD units, source timestamp, accessible tab order and text variance indicator. Test mobile and English locale, numeric sorts and optional pseudo-localization/RTL layout without authoring Persian content. A hidden field is not security. Entitlements must be loaded for the role but not shown in visuals.
Practice and references
Run python verify.py, then create the model in an authorized disposable Desktop environment if available. Record expected and actual values for the query groups, the product guard and zero denominator. Inspect Table.Distinct, Table.Group, DIVIDE guidance and accessible reports. Native M/DAX and rendering remain NOT RUN; use acceptance.md for evidence collection.