Stop 06 · Data ModelingTopics · 1/9

Fact Tables and Dimension Tables

Part of the Power BI Roadmap

In short

Most messy Power BI reports start with one giant flat table. Splitting it into facts (what happened) and dimensions (who, what, where, when) is the single biggest step towards fast, correct reports.

Fact tables hold events and numbers, like sales lines, while dimension tables hold descriptions, like products, customers and dates, used to filter and group the facts.

The jaadu sits at a restaurant counter writing short entries in a thick bill book while a single neat menu card stands beside it for reference.

Think of it like this

The bill book and the menu card

A restaurant's bill book records every sale: table 4, two dosas, ₹180, 8:15 pm. That's the fact table. The menu card describes each dish once: name, category, veg or not. That's a dimension. You don't rewrite the dish description on every bill, you just note the dish code.

Watch it happen

Fact vs dimension

Fact table (Sales)

  • One row per event, like a sale line
  • Numbers to add up: Qty, Amount
  • Keys pointing to dimensions
  • Many rows, few columns, grows daily

Dimension (Product)

  • One row per thing, like a product
  • Text to filter and group by
  • A unique key column
  • Fewer rows, more descriptive columns

Measures add up columns in facts. Slicers and axes come from dimensions.

The big ideas

What you need to know

Facts are events

Sales lines, payments, website visits, stock movements. Each row has a date, keys and numbers.

Dimensions describe

Product, Customer, Store, Date. They answer by what? questions like by city or by category.

Keys connect them

Sales[ProductKey] matches Product[ProductKey]. The dimension's key must be unique.

Grain matters

Decide what one fact row means, like one product on one bill. Every number in the table must fit that grain.

See it in code

Walk through the code

powerquery
1// Query: Product (built from the flat SalesFlat query)2let3    Source = SalesFlat,4    ProductCols = Table.SelectColumns(Source, {"ProductID", "ProductName", "Category", "Brand"}),5    UniqueProducts = Table.Distinct(ProductCols, {"ProductID"})6in7    UniqueProducts8 9// Query: Sales (the fact keeps only keys, dates and numbers)10let11    Source = SalesFlat,12    FactCols = Table.SelectColumns(Source, {"BillNo", "OrderDate", "ProductID", "StoreID", "Qty", "Amount"})13in14    FactCols

1/3Keep only the columns that describe a product.

Splitting one flat table into a Product dimension and a slim Sales fact in Power Query.

Save yourself the pain

Common mistakes

Oops

Keeping product name, category and brand on every sales row.

Do this instead

Move descriptive columns into a Product dimension and keep only ProductID in the fact.

Oops

Leaving duplicate keys in a dimension, like the same ProductID with two spellings.

Do this instead

Remove duplicates on the key so one-to-many relationships can be created.

Your mission

Split a flat file

~30 min

Quick check

Which column belongs in a dimension table rather than the fact table?

Go deeper

  1. 1Classify every table in a sample dataset as fact or dimension.
  2. 2State the grain of your fact table in one sentence.
  3. 3Move descriptive columns out of a flat fact table into dimensions.

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