Excel shows "the key didn't match any rows in the table" when a Power Query connection (or a data model relationship) is looking for a column or table name that no longer exists in the source. The quickest fix is to open the query in Power Query Editor, find the step highlighted in error, and update the reference to the current column name or re-point the step at the right table. In most cases the source file's header changed, a column was deleted, or the table was renamed.
This guide covers the Power Query and data model versions of the message, since they look similar but need slightly different handling. Menu labels in Power Query and the Data ribbon can differ a little between Excel versions, platforms and regions, so if a name is not exactly as written, look for the closest match.
What You'll Need
- Excel with Power Query (built into Excel 2016 and later on Windows; available in Microsoft 365 on Mac). The standalone Power Query add-in for older versions works the same way.
- The workbook that contains the failing query, opened on your machine rather than in a browser view.
- Access to the original source file, sheet, folder or database the query reads from, with the same permissions you had when it last worked.
- Ideally, a copy of the workbook to work in, so you can experiment without disturbing the version others rely on.
Step-by-Step
- Open the query in the editor. On the Data tab, click Queries & Connections to show the pane, then double-click the failing query. Power Query Editor opens in its own window and shows the query's applied steps on the right.
- Read the error precisely. A red error indicator appears next to the step that failed, not necessarily the step you think. Click the step name and read the message bar. If it names a specific column, note the exact spelling it expects.
- Click the step before the error. Select the last step that still shows data in the preview. That preview tells you what the data looked like just before the reference broke, which is the key diagnostic.
- Compare the headers to the reference. Look at the column names shown in the preview against the name in the failing step. If the source now says "Customer ID" but the query references "CustomerID", that mismatch is the whole problem.
- Fix the reference in place. For a renamed column, the cleanest route is the Advanced Editor: right-click the failing step, choose Advanced Editor, and correct the quoted column name in the formula. Click Done and confirm the preview loads.
- Or rebuild the step instead. Delete the failing step and redo the action (removing a column, filtering, changing type) against the current data. The new step records the new names automatically. This is often less error-prone than editing formulas by hand.
- Check for a renamed or moved table. If the error refers to a table rather than a column, verify the source table still has the same name. In an Excel source, confirm the table name on the Table Design tab; rename it back or update the query's Source step to point at the new name.
- Handle external sources carefully. For a database or SharePoint source, confirm you still have permission and that the schema has not changed. If a field was removed at the source, the query step must be edited or deleted; you cannot make Excel read a column that no longer exists.
- Refresh and test. Close and load the query, then use Refresh All on the Data tab. Confirm the output row count and a few known values look right, not just that the error disappeared.
- Check relationships if the error is a data model error. In the Power Pivot window or the Manage Data Model view, open the diagram view and look for a relationship that shows a warning. Recreate it by dragging one key column onto the matching column, then confirm the lookup columns are the same data type on both sides.
Once the query loads cleanly, set the source to be less brittle. If you control the source, avoid renaming columns without telling whoever maintains the workbook. If you do not control it, note in the query a comment explaining which columns are depended on, so the next person can spot the cause quickly.
Common Mistakes
- Editing the wrong step. The red marker sits on the failing step, but the cause is usually the step before it. Changing the failing step's formula without checking the preview often just produces a different error.
- Fixing the header instead of the query. Renaming a source column back to the old name can break other reports that use the new name. Update the query, not the shared source, unless you know nothing else depends on it.
- Forgetting trailing spaces and case. "Total " with a trailing space, or "total" versus "Total", will not match a case-sensitive reference. Check in the preview, where extra spaces are easy to miss.
- Assuming Refresh is enough. A refresh cannot repair a reference to a column that no longer exists. The step must be edited first.
- Recreating the whole query unnecessarily. A single-column rename rarely justifies rebuilding from scratch; it introduces new errors and loses careful steps such as custom columns and filters.
Tips
- Work on a copy of the workbook until the query refreshes correctly, especially if the file is shared.
- Give applied steps clear names (right-click a step, Rename) so the failing step tells you what it was trying to do.
- Keep source columns in a stable order where you can; inserting a column in the middle of a source sheet is a common trigger for positional errors.
- If a query mixes several sources, test each one with its own small query first, so a schema change is obvious before it cascades.
- Use the Advanced Editor sparingly. It is powerful but easy to break a step with a single misplaced bracket.
Troubleshooting
If the error comes back after a refresh, the source changed again, or another query feeding this one is still returning the old schema. Open every query in the chain and refresh them one at a time to find which one is stale.
If the preview is empty but shows no error, check filters earlier in the query. A filter on a renamed column can silently return nothing, which then looks like a key mismatch downstream.
If the error mentions credentials or access, sign out of the data source and sign back in from Data > Get Data > Data Source Settings, then refresh. Permission changes on SharePoint or a database are a frequent cause of queries that worked yesterday.
If nothing resolves it and the query is not too complex, duplicate it, delete all steps after the Source step, and rebuild the transformations one at a time, checking the preview after each. Note that deleting or replacing a query step discards that step's logic; keep the original query until the rebuilt one loads correctly. As a last resort, remove the query and recreate it from Get Data, but understand that any pivot tables or charts built on its output will need re-pointing.
Frequently Asked Questions
What does "the key didn't match any rows in the table" mean?
It means a step in Power Query is referring to a column or table name that the current data does not contain, usually because the source was renamed, moved or had a column removed.
Does this error mean my data is lost?
No. The source data is untouched. Only the query's reference is broken, and the data returns once the reference is corrected.
Why does it happen only sometimes after a refresh?
Refreshes re-read the source. If someone renames a header, inserts a column or renames the table between refreshes, the query notices only at the next refresh.
Can I fix it without the Advanced Editor?
Yes. Deleting the failing step and repeating the transformation is often the simplest route, and it avoids editing formula text by hand.
Is this the same as a relationship error in the data model?
Not quite. A relationship error means the two key columns do not match in name or data type. Open the diagram view and recreate the relationship after making the columns consistent.