I'm sure there are many ways to accomplish something like this. One suggestion is to use the
=UNIQUE function to output the unique rows, and the
=COUNTIFS function to count each instance.
Let's say you have your input table in cells
A2:D8. Position the cursor in the cell where you want the output table, let's say
F2, and enter the formula
=UNIQUE(A2:D). This outputs the input data, leaving out duplicates.
Position the cursor to the right of the output table, in cell
J3. In the first data row, enter the formula
=COUNTIFS(A$3:A; "=" & F3; B$3:B; "=" & G3; C$3:C; "=" & H3; D$3:D; "=" & I3).
This counts rows from the input table, which satisfies the criteria given: The
A cell value must equal the value of cell
B cell must equal
G3 and so on. The result is the number of rows of the input table that equals the (duplicate-filtered) output table.
Drag this formula down, to cover the rest of the rows.
I have set up an example spreadsheet to demonstrate, feel free to copy it.