Table.AddIndexColumn

Adds a new column to the table with the specified name newColumnName, placing it in a specific position. You can also provide an initial value (initialValue) for the index and specify the increment (i...

Syntax

Table.AddIndexColumn(table as table, newColumnName as text, optional initialValue as nullable number, optional increment as nullable number, optional columnType as nullable type) as table

About

Adds a new column to the table with the specified name newColumnName, placing it in a specific position. You can also provide an initial value (initialValue) for the index and specify the increment (increment) for each subsequent index value.

Explanation

Create a new column called "Index" in the table using Power Query M language. In the first example, the index column will start at 0 and increment by 1. In the second example, the index column will start at 10 and increment by 5. The output table will display the original data along with the newly added index column.