Power Bi group by Index

It can often be useful to create an index column in power bi. But power Query does not allow you to create a grouped index for a specific product category. Let’s predict this simple example:

Image 004.png

As you can see we have two columns, one that contains the group (column 1) and one that contains values ​​(column 2). First of all on power query we have to add the index column starting from 1 and close the window.

Image 005.png

Now that we have the index column, the next step is to create a calculated column that uses the following measure:

SequenceColumn1 =
VAR CurrentValue = Sheet2[Index]
ALLEXCEPT ( Sheet2; Sheet2[COLUMN 1] )
Sheet2[Index] <= CurrentValue


  • Current Value: is the column used to order our value. In our case is the index but we can order the column using a specific value
  • Allexcept: have to contain the column used to do the group by of countrows
  • Sheet2[Index] <= CurrentValue: is the same value used to create order

The result is :

Image 006.png

As you can see now the index is grouped by a specific attribute and is repeated for each attribute combination.