Row numbers for GroupTable from one in order

Row numbers should always start from one and go in order regardless of filter, sorting and grouping.

I tried use code from topic Auto refresh of Serial Numbers in Data Source Table, but it doesn’t work for grouping. Row numbers goes hierarchically after grouping.