Star schema in Power BI, explained

What a star schema is, facts and dimensions, why Power BI models work best in one, and how to turn a wide flat table into a star.

Short answer: a star schema splits data into fact tables, which hold the events you count and sum (sales, orders, visits), and dimension tables, which describe them (date, customer, product). Each dimension connects to the fact with a one-to-many relationship. Power BI is built for this shape: filters flow from dimensions to facts, measures stay short, and the model stays small and fast.

The most common modelling problem in Power BI is one wide table with everything in it, or a web of tables joined every way. Both work for the first report and fight back from the second.

What does a star look like?

Salesone row per order line: keys and amounts
Date
Customer
Product
Store
Sales in a star schema
Fact table
  • many rows, few columns: keys, amounts, quantities
  • you sum and count it
Dimension table
  • fewer rows, many descriptive columns
  • you filter and group by it
Facts and dimensions have different jobs

Each relationship goes from the dimension's key (one row per customer) to the fact's key (many rows per customer), and filters flow in that direction: pick a region on Customer, and Sales shows only that region's rows.

How do you get from a flat table to a star?

  1. 1
    Wide tableorder line with customer name, city, product, category
  2. 2
    Pull out each dimensiondistinct customers, distinct products, a date table
  3. 3
    Give each a keyand keep only the keys in the fact
  4. 4
    Relate one to manydimension to fact, single direction
Splitting one wide extract

In SQL, building the customer dimension from the extract is a DISTINCT:

SELECT DISTINCT CustomerID, CustomerName, City, Region
FROM stage.OrderLines;

And measures written against the star stay plain:

Revenue = SUM ( Sales[Amount] )
Revenue Vienna = CALCULATE ( [Revenue], Customer[City] = "Vienna" )

Why does it matter so much?

  • Smaller models. A city name stored once per customer instead of once per order line compresses far better.
  • Simpler DAX. Filters arrive through relationships, so measures rarely need to fight the model.
  • Fewer wrong numbers. Bidirectional and many-to-many relationships are where totals go strange; a star rarely needs either.

What goes wrong?

  • A date table missing. Time intelligence needs its own date table with every day, marked as one.
  • Dimensions related to each other. Customer to Store to Region chains (a snowflake) work, but flatten them into one dimension when you can.
  • Two-way filters as a habit. Turn on both directions only for a reason you can name.

Where can you check this?

Where do you start?

The open course DAX measures that add up works on a star like this one, and Every KPI once builds the measures on top of it.

Keep reading

More from the blog.

Every post

Next

Building this? Say hello.

A question about this post, a pattern you would build differently, or the next thing you want written out: Behnia reads every message.