EN VI

Power BI Data Model: Star Schema and Why Totals Go Wrong

By ··8 min read

Short answer

A star schema has one fact table of events, such as orders, surrounded by dimension tables that describe them, such as customers and dates. Each dimension has one row per key, and each relationship runs one-to-many with the filter flowing from the dimension to the fact. When a dimension has duplicate keys, or a bidirectional filter adds a second path, totals can add up to more than the grand total.

Now that we can build a report, we look at what sits underneath it. On a model with millions of orders, the most common wrong number in Power BI does not come from a formula. It comes from the way the tables are linked. The formula is correct, the visual is correct, and the total is still wrong, so nobody looks at the model. To avoid that, we start with the shape that works best, which is the star schema.

The star schema in one picture

TableRoleRowsExample columns
OrdersFact: one row per eventManyorder_id, customer_id, order_date, total_amount
CustomersDimension: one row per customerOne per customercustomer_id, name, city
DatesDimension: one row per dayOne per daydate, month, year

The fact table records what happened. The dimension tables describe who, when and where. Every relationship goes from the one side, the dimension, to the many side, the fact. A filter on a customer name then flows down to the orders of that customer, and a measure on Orders adds them up.

Trap 1: a dimension with duplicate keys

Marketing sends a segment list. Ruby Hoang appears twice, once as VIP and once as Active, because she qualifies for both. We load the list as a Segments table and link customer_id to Orders. Both columns now hold repeated values, so Power BI can only create a many-to-many relationship.

customer_idcustomersegment
C1Ruby HoangVIP
C1Ruby HoangActive
C2Ethan VuActive
C3Kevin DoVIP
C4Sophie LyActive

Each segment is now correct on its own. VIP holds Ruby Hoang and Kevin Do, so Total Sales is 27 + 20 = 47 million. Active holds Ruby Hoang, Ethan Vu and Sophie Ly, so it is 27 + 13 + 18 = 58 million. The grand total, with no segment filter, is still 78 million. The two segments add up to 105 million, which is 27 million more than the company sold.

SegmentTotal Sales
VIP47,000,000
Active58,000,000
Sum of the two rows105,000,000
Grand total78,000,000

The fix is to give every customer exactly one segment in the Customers dimension. If Ruby Hoang counts as VIP only, VIP is 47 million and Active is 13 + 18 = 31 million, and the two add up to 78 million. When a customer really belongs to several groups, that is a business question to settle first. A many-to-many relationship should only be used if we accept that the rows overlap.

Check for duplicate keys before you link

Before we link a dimension, we count whether its key is unique. The measure below returns 0 when every key appears once.

Duplicate Keys = COUNTROWS(Segments) - DISTINCTCOUNT(Segments[customer_id])

For the table above, there are 5 rows and 4 different customers, so the result is 1. That one extra row is Ruby Hoang's second segment.

Trap 2: bidirectional filters

By default, a filter flows in one direction, from the dimension to the fact. Setting the cross-filter direction to Both lets filters also flow from the fact back to the dimension. It can look like a shortcut, for example to make a slicer list shrink to match another selection. It also has a cost. Filters can now reach a table through more than one path. The result may then depend on which fields are in the visual, and the model can become hard to predict.

  • Keep the filter direction single, from the dimension to the fact, as the default.
  • Use Both only when you can say which question needs it, and test the totals afterwards.
  • If a result changes when you add an unrelated field to a visual, look for a second path between the tables.

A checklist for every model

  1. Each dimension has one row per key. Check it with Duplicate Keys.
  2. Each relationship is one-to-many, from the dimension to the fact.
  3. The rows of any breakdown add up to the grand total, unless the groups are meant to overlap.
  4. No relationship uses the filter direction Both without a written reason.

Frequently asked questions

What is a star schema in Power BI?

A star schema is a model with one fact table of events in the centre and dimension tables around it. Each relationship runs one-to-many from a dimension to the fact table.

Why do my breakdown rows add up to more than the total?

Usually because one record belongs to several groups, for example a dimension with duplicate keys or a many-to-many relationship. The same amount is then counted in each group.

Should I use bidirectional filters in Power BI?

Use them sparingly. A single direction from dimension to fact is the safe default, and Both can create ambiguous paths between tables.

References

Keep learning, step by step.

Each lesson in Learn has a business context, a runnable example and a result check, so you practise this habit on real questions.