Sub topic 17
Unmatched keys and the blank row
This chapter covers what Power BI does when a fact table contains key values that have no match in a dimension table. It assumes you can create a one-to-many relationship, know the difference between a fact table and a dimension table, and can write a simple measure. You should also know what a slicer and a matrix visual do.
What the blank row is
In a one-to-many relationship, each row on the many side (usually the fact table) is expected to match one row on the one side (the dimension table). Sometimes it doesn't. A sale might carry a ProductKey of 999 while the Product table has no row with that key. This is a referential integrity violation.
Power BI does not drop that sale. Instead, it adds a virtual blank member to the one-side table at query time. Every unmatched fact row is grouped under that blank member. You will see it as a row labeled (Blank) in a table or matrix, or as a (Blank) entry in a slicer.
The blank row is not stored in your data. It appears only when the relationship is evaluated. It is also called the blank member or the Blank row.
A worked example
Suppose the model has these two tables.
Product:
| ProductKey | Category |
|---|---|
| 1 | Bikes |
| 2 | Helmets |
Sales:
| SaleID | ProductKey | SalesAmount |
|---|---|---|
| 100 | 1 | 500 |
| 101 | 2 | 80 |
| 102 | 999 | 120 |
| 103 | (empty) | 60 |
A table visual with Product[Category] and SUM ( Sales[SalesAmount] ) shows:
| Category | Total Sales |
|---|---|
| Bikes | 500 |
| Helmets | 80 |
| (Blank) | 180 |
The grand total is 760, which matches the Sales table. Rows 102 and 103 both land in the blank member. Row 102 has a key with no match. Row 103 has an empty key. Power BI treats an empty key on the many side as unmatched too.
The data is all there, but it is attributed to no category. If you only looked at the named categories, you would see 580 and conclude that 180 of sales are missing.
Why the blank row matters
The blank row is a warning. It tells you the fact table references something the dimension does not describe. Common causes:
- A dimension table that was filtered or loaded from an older extract, so new products are missing.
- Keys with different formatting, such as
"A-01"in one table and"a-01 "in the other (case or trailing spaces). - Placeholder values like
0,-1, or an empty string used for "unknown" in the fact table. - Late-arriving dimension data, where a sale is loaded before the product record exists.
- Deleted or retired dimension rows that still have history in the fact table.
Rows are not lost, but reports that group by the dimension will show a confusing (Blank) group. Slicers will list it. Measures that filter by dimension attributes will exclude those rows.
Where the blank row does not appear
The blank row depends on how the relationship is set up.
- Regular one-to-many relationships. The blank member appears, as described above.
- Many-to-many relationships. There is no guaranteed "one" side, so Power BI does not add the same blank member. Unmatched rows are simply not matched, and they can disappear from visuals that group by the other table. Totals can then differ from the fact table. This is a limited relationship, covered in the many-to-many chapter.
- Relationships across different source groups (for example, an Import table related to a DirectQuery table). These are also limited relationships. The blank member is not added in the same way, and unmatched rows may be dropped from a visual.
- Relationships with "Assume referential integrity" turned on (DirectQuery only). Power BI uses an inner join instead of an outer join. Unmatched rows vanish from results, and queries run faster. Turn it on only if you are sure the data has no orphans.
The practical lesson is that the blank row is a safety net of regular relationships. When you use a limited relationship, you lose it, and mismatches become silent.
Finding unmatched keys
You can find orphan keys with a DAX query in DAX query view, or with a calculated table. This query lists keys in Sales that are not in Product:
EVALUATE
EXCEPT (
VALUES ( Sales[ProductKey] ),
VALUES ( Product[ProductKey] )
)Because VALUES on a column from the many side can return the blank member, run this carefully and check the result against the data in Power Query if the output looks odd. A more explicit check is a measure that counts the fact rows with no match:
Unmatched Sales Rows =
COUNTROWS (
FILTER (
Sales,
ISBLANK ( RELATED ( Product[ProductKey] ) )
)
)RELATED returns blank when the fact row has no matching dimension row. The measure counts those rows. If it returns anything other than 0, the model has orphans. Place it on a card visual as a data quality check.
You can also see the problem visually. Add the dimension column to a table with a measure, and look for (Blank). Compare the visual's grand total to a card that sums the fact column with no dimension filter.
Fixing unmatched keys
Choose the fix by cause.
- Clean the keys. In Power Query, trim whitespace and set consistent case with the Trim and Clean transforms. Confirm both key columns have the same data type.
- Add the missing dimension rows. Reload the dimension from a current source, or add the missing members.
- Add an "Unknown" member. Add a row to the dimension with a key such as
-1and a label such asUnknown. In the fact table, replace empty or invalid keys with-1. The sales then group under a namedUnknowncategory instead of(Blank). This is the standard data warehouse approach. - Filter out the fact rows only if they are truly invalid and the business agrees. Do this in Power Query so the removal is visible and documented.
let
Source = Sales,
FixedKeys = Table.ReplaceValue(
Source,
null,
-1,
Replacer.ReplaceValue,
{"ProductKey"}
)
in
FixedKeysThis replaces empty ProductKey values with -1. Keys such as 999 that are non-empty but unmatched need a separate fix, such as a merge against the dimension.
Blank keys in the dimension
The reverse case also exists. A dimension row can have no sales. That is not an integrity problem. Product 3 with no sales simply does not appear in a visual that uses a measure like SUM ( Sales[SalesAmount] ), because the measure returns blank and the visual hides blank rows. Adding + 0 to the measure makes it show 0 for every product, but this also produces rows for every dimension member in every context, so use it with care.
A dimension that contains a real blank or null key is a different problem. Duplicate or null keys on the one side prevent a one-to-many relationship from being created, because the one-side column must hold unique values.
How the blank row affects filtering
The blank member behaves like a real member when filtering flows from the dimension to the fact table. If a slicer selects (Blank), only the unmatched fact rows remain. If a slicer selects Bikes, unmatched rows are excluded.
Filter direction matters too. With single direction filtering (dimension to fact), a slicer on Sales cannot remove blank rows from the Product slicer. The (Blank) entry stays even when no sales are unmatched in the current selection, unless both-direction filtering narrows the list.
Summary of the diagnostic approach
The following flow shows how to react when you see (Blank) in a visual.
Exercise
A Sales table has total SalesAmount of 10,000. A matrix grouped by Product[Category] shows Bikes 6,000, Helmets 3,500, and a (Blank) row of 500. The relationship is a regular one-to-many from Product to Sales. What does the (Blank) row mean, and what is one way to make it show a meaningful label?
Show answer
The 500 belongs to Sales rows whose ProductKey is empty or has no matching row in Product. Power BI groups them under the blank member so the total still equals 10,000. To get a meaningful label, add an Unknown row with a key such as -1 to the Product table and replace the empty or invalid keys in Sales with -1 in Power Query. After that, the 500 appears under Unknown instead of (Blank).
Exercise
You change a relationship to many-to-many and the matrix grand total drops below the Sales table total. Why can unmatched rows disappear here, when they did not with a regular one-to-many relationship?
Show answer
A regular one-to-many relationship has a guaranteed one side, so Power BI adds a blank member to hold unmatched fact rows. A many-to-many relationship is a limited relationship and does not add that blank member. Fact rows with no match are not attributed to any dimension member, so they drop out of visuals grouped by the dimension, and the total no longer equals the Sales table total.