Power QueryExercises

Expression.Error: The key matched more than one row in the table

By Tahir Nas · Examples run in our simulator · Updated

Expression.Error: The key matched more than one row in the table.

A row lookup like Table{[Key = "A"]} requires exactly one matching row. The table has duplicates of that key, so M refuses to guess which row you meant.

Common causes

How to fix it

  1. Remove duplicates on the key column before looking up: Table.Distinct(table, {"Key"}).
  2. If several matches are valid, filter with Table.SelectRows and take the first deliberately with Table.First or {0}.
  3. In navigation steps, also match on Kind: Source{[Item = "Sales", Kind = "Table"]}[Data].

Find the step that fails

Minimal example

Raises the error:

#table({"Code", "Rate"}, {{"EUR", 0.85}, {"EUR", 0.86}}){[Code = "EUR"]}[Rate]

Fixed:

Table.Distinct(#table({"Code", "Rate"}, {{"EUR", 0.85}, {"EUR", 0.86}}), {"Code"}){[Code = "EUR"]}[Rate]

Both snippets are run by the Power Query Exercises simulator on every build: the first must raise Expression.Error, the second must run.

Practise avoiding it

Related lessons

Similar errors