6.1 普通分组:按字段值
有日销售统计表如下所示,请算出每种产品的总销售额
Date | Product | Sales |
---|---|---|
2022-01-01 00:00:00 | Cereal | 98.0000 |
2022-01-01 00:00:00 | Meat | 174.0000 |
2022-01-02 00:00:00 | Cereal | 168.0000 |
2022-01-02 00:00:00 | Meat | 167.4000 |
2022-01-03 00:00:00 | Cereal | 1696.0000 |
… | … | … |
脚本:
A | |
---|---|
1 | =T(“DailySales.xls”) |
2 | =A1.groups(Product;sum(Sales):Sales) |
3 | =A1.group(Product;~.sum(Sales):Sales) |
A2 分组的同时进行聚合运算,不产生分组子集
A3 先产生分组子集,再对子集做聚合运算,结果和 A2 相同
运行结果:
Product | Sales |
---|---|
Cereal | 309998 |
Meat | 174645 |