Power QueryExercises

Expression.Error: There weren't enough elements in the enumeration

By Tahir Nas · Examples run in our simulator · Published · Updated

Expression.Error: There weren't enough elements in the enumeration to complete the operation.

Code asked for a list item or table row that doesn't exist, such as {0} on an empty list or Table.First of an empty table used later.

Common causes

How to fix it

  1. Check List.IsEmpty or Table.IsEmpty before positional access.
  2. Use List.First(list, default) with a default value.
  3. Use the optional ? operator: list{0}? returns null instead of an error.

Find the step that fails

Minimal example

Raises the error:

{}{0}

Fixed:

{}{0}?

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

Guides

Related lessons