4 suggestions in Sheet2 of the attached.
In the top solution, hard code values in A3:A4, then see formulae in cell B3:B4. This formula can be copied down.
In the 2nd solution, hard code the values in cells A8:A9 and see the formulae in cells B8:H9. These formulae can all be copied down/across.
Below that two pivot table solutions. These pivots depend on there being only one line per scrip in the source data.
Since you're using power query you could go direct to a pivot table obviating the need for the table in Sheet1