Sub topic 17
Unmatched keys and the blank row
This chapter assumes you can create a one-to-many relationship in the Model view and read a table visual. It covers what happens when a fact table holds key values that the dimension table does not.
Why the blank row appears
A one-to-many relationship expects every key in the many-side table to exist in the one-side table. This expectation is called referential integrity. Power BI does not enforce it when it loads data. If a row in Sales has a ProductKey that is missing from Product, the load still succeeds.
Power BI handles those orphan rows by adding a virtual blank row to the one-side table. Every unmatched fact row is grouped under that blank member. You will see it as a "(Blank)" category in a visual that groups by a Product column.
A worked example
Suppose Sales contains these rows, and Product lists only keys 1 and 2.
| ProductKey | SalesAmount |
|---|---|
| 1 | 100 |
| 2 | 150 |
| 9 | 75 |
A table visual with Product[Category] and [Total Sales] shows each category with its sales, plus a "(Blank)" row of 75. The grand total is 325, because the orphan row still counts. A card visual with no grouping also shows 325, so the card and the sum of the named categories disagree. This is the usual symptom of unmatched keys.
Finding the orphan keys
Check for unmatched keys with a measure that counts fact rows that have no match in the dimension.
Unmatched Sales Rows =
COUNTROWS (
FILTER (
Sales,
ISBLANK ( RELATED ( Product[ProductKey] ) )
)
)Put this measure in a table visual next to Sales[ProductKey]. Any key with a non-zero count has no match in Product. Note that RELATED returns blank for these rows, which is why the test works.
Fixing the cause
Choose the fix that matches the cause.
- Add the missing products to the dimension table, if the source data is incomplete.
- Correct the keys in the fact table, if they contain typos, extra spaces, or the wrong case.
- Replace placeholder keys such as 0 or -1 with a real "Unknown" row in the dimension. This makes the group visible and named instead of blank.
- Filter out the orphan rows in Power Query, only if you are sure they should not be reported.
Many-to-many relationships
Many-to-many relationships have no guaranteed one side, so Power BI does not add a blank row. Unmatched rows on either side drop out of grouped results without any visible marker. Check key coverage yourself in these models.
Exercise
A table visual grouped by Product[Category] shows a "(Blank)" row with 75 in sales, and no such row exists in the Product table. What is the most likely cause, and how do you confirm it?
Show answer
Sales contains a ProductKey that does not exist in Product, so Power BI groups those rows under a virtual blank row. Confirm it by adding Sales[ProductKey] to a table with a measure that counts rows where RELATED(Product[ProductKey]) is blank. Keys with a non-zero count are the orphans.