Power Query: Add a Column with a custom Group ID

jajatidev

Board Regular
Joined
Jul 29, 2016
Messages
78
Office Version
  1. 365
Platform
  1. Windows
Hi,
In Excel, I used the below function to count the number of rows to assign them a group ID like "G1, G2, G3".
In total, I had 8 groups roughly having 3000 rows each.

Excel Formula:
=INDEX($A$2:$A$9,MOD(ROWS(D$11:D11)-1,$A$1)+1)

The objective of this was to split table content into 8 groups and execute the extraction separately in SAP to prevent runtime errors.
Please advise how to replicate this in the power query.
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Maybe try with the code below. The offset is the number of items you want inside a group.
Power Query:
Table.Split(Table, Offset)
 
Upvote 0
Solution
Maybe try with the code below. The offset is the number of items you want inside a group.
Power Query:
Table.Split(Table, Offset)
Hi,
Thanks, for the solution. However, I do not wish to split the table. The exercise is to group the data.
The requirement is to count the number of rows in the data set excluding the header. the in a new column assign Group IDs like G1, G2, G3 etc. I have maintained the sequence from G1 to G8
I wish to replicate the Excel formula in power query to reduce manual intervention.
 
Upvote 0
The idea is to add an index to each subtable. Then combine the tables again.
The outcome is you have created groups.

You can add a step where you do a table.rowcount of the source table. Then divide by 8. And roundup. Split source again by the last number.

In my head this is doing the same as you do with the excel formula. Except it is not on each row, it is on each block of data.
 
Upvote 0
Glad to assist. Thanks for the mark as solution.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,160
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top