Project · Power BI report fix
Rebuilding a sales report as a star schema, checked number by number
The problem
The sales report takes ages to open, some totals look wrong, and people go back to Excel because they stopped trusting it.
The solution
The slow report's flat model rebuilt as a star schema with a date table, its slow DAX rewritten, and every number checked against SQL before and after. Handed over with a build guide and a change log.
How it works
- Measure: One timing method for every page, before and after: Performance Analyzer and DAX Studio from a cold cache
- Model: The flat table rebuilt as a star schema with a proper date table
- DAX: Slow measures rewritten with variables and filter context done right
- Check: Every card, chart and table checked against SQL, the same in both reports
- Hand over: Both reports, a step-by-step build guide and a note of every change
A closer look
The code
overview = q('''
SELECT count(*) AS sales_rows,
count(DISTINCT order_key) AS orders,
count(DISTINCT customer_key) AS customers,
count(DISTINCT product_key) AS products,
min(order_date) AS first_order,
max(order_date) AS last_order,
round(sum(quantity * net_price)) AS sales_all_years
FROM sales
''')The impact
- A lean model: each name stored once, no hidden date tables, no calculated columns.
- Totals that add up, checked against the source.
- Every change listed in a note, with a step-by-step build guide for the next developer.
The result
2,098,633 sales rows: a 35-column table rebuilt as a 4-table star schema, every check number worked out in SQL so both reports match.