let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Removed Columns" = Table.RemoveColumns(Source,{"AVERAGE"}),
#"Filtered Rows" = Table.SelectRows(#"Removed Columns", each ([NEW CODE] <> null)),
#"Removed Columns1" = Table.RemoveColumns(#"Filtered Rows",{"OLD CODE"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns1", {"NEW CODE", "MATERIAL"}, "Attribute", "Value"),
#"Grouped Rows" = Table.Group(#"Unpivoted Other Columns", {"NEW CODE"}, {{"Average Sales", each List.Average([Value]), type number}})
in
#"Grouped Rows"