I am looking for a solution on row aggregation as follows. We have in the example of the recording of three users.

We look at the author's ID: if the next line (s) belong to the author and the dates in these next lines are adjacent, then there must be a cluster of adjacent (or current dates). October 12,14 are not neighboring, 10,10,10,11,11,11,12 are neighboring. 14,15,16,16,16,16 - neighboring.

then we aggregate, otherwise we skip.

If a cluster of neighboring dates is found in the author's records, then replace it with the record:

  • the first column is the sum of the values ​​of all the numbers in the first column of the cluster of records
  • the second is the average date.
  • The third is the sum of the numbers in the corresponding column.
  • The fifth is the sum of the numbers in the corresponding column.

That is, instead of records we insert one "aggregated" record. All other values ​​of this record in other columns are put down with values ​​from any record from the cluster (the same values ​​are there).

enter image description here

Nameplate

enter image description here

csv-shka

  • Solution found - Alexandr Kosolapov

0