This formula based proposal employs a lot of helper columns on the Before. Raw Data sheet.
Columns R:AB are populated using: =IF(G3=0,"",SUM($B3,$G3:G3))
Columns AC:KD are populated using:
Formula:
=IF(AC$1<$B3,"",IF(AC$1=$B3,INDEX($R$2:$AB$2,AGGREGATE(15,6,(COLUMN($R$2:$AB$2)-COLUMN($Q$2))/($R3:$AB3<>""),1)),IFERROR(INDEX($R$2:$AB$2,AGGREGATE(15,6,(COLUMN($R$2:$AB$2)-COLUMN($Q$2))/($R3:$AB3<>"")/($R3:$AB3>AC$1),1)),AB3)))
On the After. Example Reports sheet columns AB:AM are populated using: =SUMPRODUCT(('Before. Raw Data'!$F$3:$F$22)*('Before. Raw Data'!$AC$1:$KD$1=$AB3)*('Before. Raw Data'!$AC$3:$KD$22=AC$2))
Note that some formula results differ from those in columns A:L. I have set conditional formatting to highlight the differences, which start in row61, in yellow.
Let us know if you have any questions.
Bookmarks