Stop 06 · Data ModelingTopics · 7/9

Star Schema vs Snowflake Schema

Part of the Power BI Roadmap

In short

Data warehouses love snowflakes: Product links to Subcategory, which links to Category. Power BI prefers you flatten that chain into one Product table. Here's why and how.

A snowflake schema splits dimensions into further related tables, like Product to Subcategory to Category. Power BI works best when you flatten these back into single dimensions.

The jaadu happily pulls a paper from one open drawer while a pile of nested boxes, each inside another, sits unopened beside it.

Think of it like this

One folder vs folders inside folders

Finding a bill in one well-labelled folder is quick. Finding it inside Year, then Month, then Shop, then Type folders means opening four doors every time. A snowflake makes Power BI open several doors for each filter. A star puts it all in one folder.

Watch it happen

Snowflake vs star for Power BI

Snowflake

  • Product to Subcategory to Category
  • Less repetition in storage
  • More relationships to manage
  • Longer filter paths and messier field list

Star

  • One Product table with all levels
  • Some text repeats, but compresses well
  • One relationship per dimension
  • Simple for report builders

In Power BI, merge snowflaked tables into one dimension in Power Query.

The big ideas

What you need to know

What snowflaking is

A dimension split into a chain of related tables, normalised like a transactional database.

Flatten with Merge

Merge Subcategory and Category into Product in Power Query and expand the name columns.

Build hierarchies

Once flat, create a Category > Subcategory > Product hierarchy for drill-down.

Exceptions exist

Very large dimensions or tables shared at different grains may stay separate, but start with flat.

See it in code

Walk through the code

powerquery
1let2    Source = ProductRaw,3    WithSub = Table.NestedJoin(Source, {"SubcategoryKey"}, Subcategory, {"SubcategoryKey"}, "Sub", JoinKind.LeftOuter),4    ExpandSub = Table.ExpandTableColumn(WithSub, "Sub", {"SubcategoryName", "CategoryKey"}),5    WithCat = Table.NestedJoin(ExpandSub, {"CategoryKey"}, Category, {"CategoryKey"}, "Cat", JoinKind.LeftOuter),6    ExpandCat = Table.ExpandTableColumn(WithCat, "Cat", {"CategoryName"}),7    Final = Table.RemoveColumns(ExpandCat, {"SubcategoryKey", "CategoryKey"})8in9    Final

1/4Left join Subcategory on its key and bring in its name and the CategoryKey.

Flattening a three-level snowflake into one Product dimension.

Save yourself the pain

Common mistakes

Oops

Loading Product, Subcategory and Category as three related tables.

Do this instead

Merge them into one Product table. Filters and the field list get simpler.

Oops

Using an inner join when flattening.

Do this instead

Use a left outer join so products without a subcategory aren't silently dropped.

Your mission

Melt a snowflake

~25 min

Quick check

What's the usual Power BI recommendation for a snowflaked Product dimension?

Go deeper

  1. 1Merge a snowflaked product hierarchy into one Product table.
  2. 2Compare the number of relationships before and after.
  3. 3Be able to explain the difference in an interview.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge