Skip to main content

Power Query: Create row number for each group in Excel

Author: Xiaoyang Last Modified: 2022-12-08

Have you ever tried to create sequence row number for each group in Excel worksheet as below screenshot shown? Normally, you can create a formula to solve this task. But, in this article, I will introduce how to deal with this job by using the Power Query in Excel.


Power Query: Create row number for each group in Excel

To generate the index numbers for each group of the data, the Power Query can do you a favor. Please do with the following steps:

1. Select the data range that you want to insert the row number. In Excel 2019 and Excel 365, click Data > From Table/Range, see screenshot:

Note: In Excel 2016 and Excel 2021, click Data > From Table, see screenshot:

2. In the Create Table dialog box, click OK button to create a table, see screenshot:

3. And then, in the opened Power Query Editor window, select the column that you want to use to group the table, then right click it. And then, choose Group By from the context menu, see screenshot:

4. In the Group By dialog box:

  • Select the column name that you want to insert the row number based on from the drop-down list;
  • Select All Rows option from the Operation drop-down list;
  • Click OK button.

5. Now, return to the Power Query Editor window, click Add Column > Custom Column, see screenshot:

6. In the Custom Column dialog box, using the Table.AddIndexColumn function as below screenshot show:

  • Type a new column name into the New column name text box;
  • Then, enter this formula: =Table.AddIndexColumn([Count],"Index",1) into the Custom column formula box;
  • At last, click OK button.

Note: In the above formula, [Count] is the name of the column you have created in step 4, please change it to your need.

7. Now, return to the Power Query Editor window, you should remove all other columns and only keep the last column you have created. Right click the last column name you are created, select Remove Other Columns, see screenshot:

8. Then, expand this column, click the Expand icon next to the column title. In the expanded box, check Expand option, and then check all the column names from the list box, and uncheck the Use original column name as prefix option. And finally, click OK button. See screenshot:

9. And now, you can see the row index numbers are displayed as below screenshot shown:

10. Then, please click Home > Close & Load > Close & Load to load the data into a new worksheet, see screenshots:

 

Best Office Productivity Tools

🤖 Kutools AI Aide: Revolutionize data analysis based on: Intelligent Execution   |  Generate Code  |  Create Custom Formulas  |  Analyze Data and Generate Charts  |  Invoke Kutools Functions
Popular Features: Find, Highlight or Identify Duplicates   |  Delete Blank Rows   |  Combine Columns or Cells without Losing Data   |   Round without Formula ...
Super Lookup: Multiple Criteria VLookup    Multiple Value VLookup  |   VLookup Across Multiple Sheets   |   Fuzzy Lookup ....
Advanced Drop-down List: Quickly Create Drop Down List   |  Dependent Drop Down List   |  Multi-select Drop Down List ....
Column Manager: Add a Specific Number of Columns  |  Move Columns  |  Toggle Visibility Status of Hidden Columns  |  Compare Ranges & Columns ...
Featured Features: Grid Focus   |  Design View   |   Big Formula Bar    Workbook & Sheet Manager   |  Resource Library (Auto Text)   |  Date Picker   |  Combine Worksheets   |  Encrypt/Decrypt Cells    Send Emails by List   |  Super Filter   |   Special Filter (filter bold/italic/strikethrough...) ...
Top 15 Toolsets12 Text Tools (Add Text, Remove Characters, ...)   |   50+ Chart Types (Gantt Chart, ...)   |   40+ Practical Formulas (Calculate age based on birthday, ...)   |   19 Insertion Tools (Insert QR Code, Insert Picture from Path, ...)   |   12 Conversion Tools (Numbers to Words, Currency Conversion, ...)   |   7 Merge & Split Tools (Advanced Combine Rows, Split Cells, ...)   |   ... and more

Supercharge Your Excel Skills with Kutools for Excel, and Experience Efficiency Like Never Before. Kutools for Excel Offers Over 300 Advanced Features to Boost Productivity and Save Time.  Click Here to Get The Feature You Need The Most...

Description


Office Tab Brings Tabbed interface to Office, and Make Your Work Much Easier

  • Enable tabbed editing and reading in Word, Excel, PowerPoint, Publisher, Access, Visio and Project.
  • Open and create multiple documents in new tabs of the same window, rather than in new windows.
  • Increases your productivity by 50%, and reduces hundreds of mouse clicks for you every day!
Comments (0)
No ratings yet. Be the first to rate!
There are no comments posted here yet
Leave your comments
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations