Data modeling

A star schema in Power BI, in five steps

One wide spreadsheet works until it does not: every column repeats, filters get ambiguous and DAX starts returning numbers that are wrong in ways nobody notices. A star schema — one fact table surrounded by small dimension tables — fixes the structure once, and every visual and measure inherits the fix.

One fact tableFour dimensionsDate table required
P
Target modelFact + 4 dimensions + date
15 min read
FactSalesmany
DimDate1 → many
DimProduct1 → many
DimCustomer1 → many
DimRegion1 → many
InputOne flat sales export
OutputFact + dimensions
Key ruleOne side to many side
Never doBidirectional filters by default
Why it matters

What a wide sheet actually costs

Wrong numbers, not slow reports

With everything in one table, a slicer on "Category" filters rows of sales. When the same category name appears with different casing or trailing spaces, the filter splits it into two and the total looks short.

Repeated attributes

Product name, category and price repeat on every sales row. A 2 million row export can carry 1.9 million duplicated text strings — file size grows, refresh slows, and one rename becomes a full reload.

DAX without context

Time intelligence needs a table of dates, not a date column. Ratios need a clean "one row per order". Neither exists in a flat export, so the measures get complicated instead of the model getting correct.

Five steps

From one export to a model DAX can trust

Step 1 · Decide the grain of the fact table

The grain is what one row means: one order line, one invoice line, one day per product. Write it down in a sentence before touching Power Query, because every later decision depends on it. A fact table at order-line grain can always be aggregated up; a fact table that mixes grains cannot be fixed later without rebuilding.

If two rows can describe the same real-world event, the grain is wrong. Duplicate rows double every SUM.

Step 2 · Build the fact table: keys and numbers only

Keep the fact table narrow. It should contain the foreign keys (DateKey, ProductKey, CustomerKey, RegionKey) and the numeric measures (Quantity, UnitPrice, Discount, Amount). Remove descriptions, categories and names — they belong in dimensions.

FactSales
  DateKey      (int, YYYYMMDD)
  ProductKey   (int)
  CustomerKey  (int)
  RegionKey    (int)
  Quantity     (int)
  Amount       (decimal)

In Power Query, this is a "Reference" of the source query with the descriptive columns removed, not a second import of the same file.

Step 3 · Build one dimension per attribute group

Each dimension gets a single-column key, unique per row, and the attributes users filter by. Four dimensions cover most sales models: product, customer, region and date.

DimProduct
  ProductKey   (int, unique)
  ProductName
  Category
  Subcategory

DimRegion
  RegionKey    (int, unique)
  Country
  Region
  City

Deduplicate inside Power Query: select the key column and use Remove Duplicates, or group by the key and keep the latest attribute row. A dimension with duplicate keys makes the relationship many-to-many and silently breaks filters.

Step 4 · Add a date table and mark it

Do not use the date column in the fact table. Create a separate table with one row per day, no gaps, covering every date in the data plus the full current year.

DimDate =
ADDCOLUMNS(
    CALENDAR( DATE( 2022, 1, 1 ), DATE( 2026, 12, 31 ) ),
    "Year",        YEAR( [Date] ),
    "MonthNumber", MONTH( [Date] ),
    "Month",       FORMAT( [Date], "mmm" ),
    "Quarter",     "Q" & QUARTER( [Date] )
)

Then right-click the table in the model view and choose Mark as date table, pointing at the Date column. Without that step, SAMEPERIODLASTYEAR and friends either fail or return blanks. Sort the Month column by MonthNumber so charts read January to December rather than alphabetically.

Step 5 · Create the relationships, one way

Drag each dimension key onto the matching fact key. Power BI should detect one-to-many with the dimension on the one side and the fact on the many side. Confirm the cross filter direction is Single, then hide the key columns from report view so nobody builds a visual on a number.

If Power BI proposes many-to-many, the dimension has duplicate keys. Fix the data, do not accept the relationship.

Relationship mistakes

The four that break DAX without an error message

MistakeSymptomFix
Many-to-many accepted "because it works"Totals double or drift as data growsDeduplicate the dimension key, rebuild the relationship
Bidirectional filter left on by defaultFilters leak between facts; performance collapses on large modelsKeep single direction; use CROSSFILTER in one measure if a specific case needs it
Date column in the fact table instead of a date tableSAMEPERIODLASTYEAR returns blank or wrong valuesCreate DimDate, mark it, relate it, use its columns in visuals
Keys hidden but not removed from visualsUsers drag a key into a chart and get meaningless rowsHide keys in report view; keep only attributes visible
FAQ

Common questions about star schema

Do I need a star schema for a small model?

For a single table under a few thousand rows and one page of visuals, a flat table is fine. The moment you need a slicer to filter two different facts, time intelligence, or a second data source, the schema pays for itself.

Can I have more than one fact table?

Yes, and it is normal: sales and budget are separate facts. Each gets its own relationships to the shared dimensions. Do not merge them into one table with a "type" column unless the grain truly matches.

What about snowflaking — should dimensions be split further?

Usually no. Star schemas are faster and simpler to navigate. Flatten product category and subcategory into DimProduct rather than creating a separate category table, unless the category table has attributes you genuinely need at that level.

How do I test that the model is correct?

Compare a card with SUM(FactSales[Amount]) against the same total computed in Excel or SQL. Then slice by each dimension: the sum of every slice must equal the total. Any mismatch points to a relationship or duplicate key.

Does a star schema make DAX easier?

Substantially. Simple SUM and CALCULATE measures become correct because the filter context is unambiguous. See the six measures that cover most reports for the practical side.

Next

Model done — now the measures

Six DAX measures

Sales, orders, average order value, year over year, share of total and running total, with copy-ready code.

Read the DAX guide

A finished model to inspect

The templates already use this structure: one fact, small dimensions, a marked date table and measures on top.

Browse templates