GOOGLE SHEET 按拆分单元格文本求和

GOOGLE SHEET SUM by Split Cell Text

试图找到一个简单的解决方案,将每种类型的建筑 material 总结在 table 中,如下所示:

A(id) B(WallType) C(Quantity))
1 brick, drywall 25
2 drywall, stud, drywall 10
3 drywallFire, stud, drywallFire 20
4 drywallFire, drywallFire, stud, drywallFire, drywallFire 30

B 列是 material 代码的组合,由“,”连接。例如,

是否有公式组合来获得 material 和数量的列表(唯一)?

Material Sum
brick 25
drywall 45
drywallFire 160
stud 60

使用:

=INDEX(QUERY(SPLIT(TRIM(FLATTEN(SPLIT(B2:B, ",")&"♦"&C2:C)), "♦"),
 "select Col1,sum(Col2) where Col2 is not null group by Col1 label sum(Col2)''"))