Floren
Floren

Reputation: 55

Power Query: Index for each new set of elements in a column

I have a column in a table that indicates a group identification and I would like to generate an index that goes from 1 to the number of times that group appears, for each of the groups. And then of course there are other columns with data

Example:

Example table

So, how do I generate the Index column from the Group ID column?

Upvotes: 0

Views: 2628

Answers (1)

horseyride
horseyride

Reputation: 21393

Right click Group ID, Group By, keep name, use operation All Rows

Change the code in the window from

= Table.Group(#"Changed Type", {"Group ID"}, {{"Count", each _, type table ....

to

= Table.Group(#"Changed Type", {"Group ID"}, {{"Count", each Table.AddIndexColumn(_, "Index", 0, 1, Int64.Type), type table}})

Expand using arrows atop column

Upvotes: 1

Related Questions