Add an index column (Power Query)

Applies To
Excel for Microsoft 365 Excel for Microsoft 365 for Mac

Create an index column to assign a sequential number to each row in a query. This feature is especially useful when you filter by row position or by a range of rows, and it can help you verify query results after sorting or filtering.

Common uses

You can use an index column to:

  • Preserve row order after transformations
  • Filter rows by position
  • Create unique row identifiers
  • Support merge and transformation scenarios that depend on row position
  • Verify query results after sorting or filtering

To open a query

  1. Locate one previously loaded from the Power Query Editor, select a cell in the data, and then select Query > Edit. For more information, see Create, load, or edit a query in Excel (Power Query).

  2. Select Add Column > Index Column. The default behavior is to start numbering the first row at 0. Alternatively:

    • If you select the arrow and select From 1, you can start numbering the rows at 1.

    • If you select the arrow and select Custom, you can enter a Starting Index and Increment to specify a different starting number and increment value. For example, if you enter a Starting Index of 100 and an Increment of 1, the rows are numbered 100, 101, 102, and so on.

Result

A column named Index is added to the end of the query. You can rename the column and move it to a different position if needed. When the query is loaded, the index column becomes part of the query output. For more information, seeĀ Rename a column (Power Query).

See also

Power Query for Excel Help

Add an index column