Adding an Index Column in Power Query Editor

An index column in Power Query Editor is used to add a new column with a sequential list of numbers to each row. These values can be used to uniquely identify each row.

The index column is similar to the Identity function in SQL Server. Just like the Identity function, the Index column option supports a start value and an increment value.

Let's understand how to add an Index Column to a table.

Step 1: Generate a Table with a List of Countries and Their Capitals Using ChatGPT.



























Step 2: To add an index column, select the table and navigate to the Index Column section under the Add Column tab. This section provides a dropdown menu with options to choose from:

From 0: Starts the index values from 0 and increments by 1.
From 1: Starts the index values from 1 and increments by 1.
Custom: This is the most commonly used option, allowing you to choose the start value and increment value.
Let's see this in practice.

From 0:































From 1:






























Custom : Here let us use 100 as the start value and 10 as the increment value. Follow the below steps to implement the Custom Index values.
  1. Select your table in Power Query Editor.
  2. Go to the Add Column tab.
  3. Click on the Index Column dropdown.
  4. Choose Custom.
  5. Set the start value to 100 and the increment value to 10.













































Under the Custome Option, It's not necessary to use only positive numbers; you can also use negative numbers. Here, we'll create a new index column with -1 as the start value and an increment value.























I hope this article helped you understand the creation and use cases of Index columns. If you have any doubts, please mention them in the comments section below.



No comments:

Post a Comment