简体   繁体   English

如何用标准求和

[英]how to sum in excel with a criteria

First two columns contain data. 前两列包含数据。 In the third column I put on the criteria to sum by. 在第三栏中,我提出了总结依据。 For example, when I put A, B, D in the third column, I want to sum values in the second column when values in the first column are AB or D; 例如,当我在第三列中放入A,B,D时,当第一列中的值为AB或D时,我想对第二列中的值求和; that is 1+2+4+5+7. 即1 + 2 + 4 + 5 + 7。 When I put A, B in the third column, I get 1+2+5, so on so forth. 当我在第三列中放入A,B时,得到1 + 2 + 5,依此类推。 How to do it in a sumif function (or other sum functions)? 如何在sumif函数(或其他sum函数)中执行此操作? Thanks. 谢谢。

在此处输入图片说明

If you need to sum all values satisfying any one criteria from all criterias , you can use following formula: 如果需要对所有条件中满足任何一个条件的所有值求和,则可以使用以下公式:

=SUMPRODUCT(NOT(ISNA(MATCH(A:A,D1:D3,0)))*1,B:B)

where A:A contains your data with "A", "B", "C", "D" and so on, B:B contains corresponding numbers, and D1:D3 contains your search criterias, ig "A" and "B" and "D". 其中A:A包含带有“ A”,“ B”,“ C”,“ D”等的数据, B:B包含相应的数字, D1:D3包含您的搜索条件,例如“ A”和“ B” ”和“ D”。

PS if you don't know exact count of criterias in column D , you can change D1:D3 to D1:D100 or D:D . PS如果您不知道D列中标准的确切数量,则可以将D1:D3更改为D1:D100D:D But D:D will make your formula a little slower.. 但是D:D会使您的公式变慢一些。

Assuming that your leftmost column pictured above is column A and the first row pictured is row 1, your formula in E1 should be 假设上图中最左边的列是A列,而上图的第一行是第1行,则E1中的公式应为

=SUMIF(A:A,D1,B:B)

An alternate approach would be to use a pivot table. 另一种方法是使用数据透视表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM