Create group or sorting items on datatable


I need your help to find the best approach to solve the following case.

I have one datatable with various values where I need to handle the values on different ways according to the value of certain column.

For example, first I have to group all the rows that have the same value on the column A, then group all the rows that have the same value on the column B to be able to process the values of columns C and D but in the end I need to process all the rows of the datatable even the ones with unique values on column A.


Even if we are grouping the data with A and B columns, we will get all the 9 rows here based on your sample data, since there is no duplication.

I still want the 9 rows but I want to identify the columns C and D values based on filtering the same value on column A first and having the same value on column B.

On my example I repeated the value on columns by mistake but my real case will only have repeated values on the same column.

For example, I want to identify that for the value A1 on column A I have more than 1 row in column B with the value B1 and then do a for each to every row resulting of that sort, this way it will result in 3 rows for the column A value A1, column B value B1.

Have a look on this post:

that linked case looks similar to your scenario