EXcel,将月份为1月份的不同产品数量相加

时间:2016-02-17 10:29:04

标签: excel sum distinct product

我在Excel中有一个表:

Date               Product           Quantity

1/4/2016             A               3

1/4/2016             B               2

1/8/2016             A               7

2/3/2016             B               5

2/5/2016             B               1

2/8/2016             A               4

我需要计算1月份销售的A产品数量(无论是当天,仅仅是一个月),f.e:

A in January was sold 10,
B in January was sold 2,
A in February was sold 4
B in Feruary was sold 9

2 个答案:

答案 0 :(得分:1)

您可以使用SUMPRODUCT,例如:

=SUMPRODUCT(--(MONTH(A1:A2)=1) * (B1:B2="A") * C1:C2)

在上面我假设日期在A列,产品在B列和你要在C中求和的范围。另外,因为它只是一个例子,我只是将前两行相加

我引用了SO here

答案 1 :(得分:1)

您也可以使用SUMIFS: -

=SUMIFS(C:C,B:B,"A",A:A,">="&DATEVALUE("1/1/2016"),A:A,"<"&DATEVALUE("1/2/2016"))

=SUMIFS(C:C,B:B,"A",A:A,">="&DATE(2016,1,1),A:A,"<"&DATE(2016,2,1))

我的日期是DD / MM / YYYY格式。

但是如果你想为日期和产品的许多组合重复它,你可能最好将月份放入一个单独的列并使用数据透视表。