Automatically Number Rows With Power Query

Power Query’s Index Column numbers every row and renumbers when you refresh, so new or removed rows never break the sequence. You can start at any number and add prefixes like INV-0150.

WhereAdd Column → Index Column
RefreshRenumbers automatically
Works inExcel 2016 and later

Step 1: Load the data

Click in the data → Data → From Table/Range → OK.

Sales data to number
Data loaded into the Power Query Editor

Step 2: Add the index

Add Column → Index Column → From 1. Rename the column (double-click its header) and move it with right-click → Move → To Beginning.

Index Column menu with From 1
Index column numbering the rows

Step 3: Load and refresh

Home → Close & Load To → Existing worksheet. When the source changes, right-click the result → Refresh.

Numbered table loaded into Excel
Serial numbers updating after refresh

Custom start and prefix

Choose Index Column → Custom to set the starting number and step, for example start 150, step 1.

Add Index Column dialog with starting index 150

For a code like INV-0150, add a Custom Column:

"INV-" & Text.PadStart(Text.From([Index]), 4, "0")

Or use Add Column → Format → Add Prefix for a simple prefix without padding.

Customised serial numbers with a prefix

Number within groups

To restart numbering for each group, such as each region, use Group By with All Rows, add an index inside each group with a custom column Table.AddIndexColumn([Rows],"No",1), then expand.

Related