简体   繁体   English

Excel - 基于另一列中的不同值的总和值

[英]Excel - sum values based on distinct value in another column

I have the following structure in an Excel worksheet: 我在Excel工作表中有以下结构:

ARTICLE     VALUE
-------     -----
   A         300
   B         100
   A         300
   C         300
   D         200
   A         300

I can always expect that the value for a similar article will be the same. 我总能指望类似文章的价值是一样的。 Therefore, the value of A will always be 300. However, other articles could very well have a similar value as a previous article. 因此,A的值总是300.但是,其他文章很可能具有与前一篇文章类似的价值。 Hence, C also has a value of 300. 因此,C的值也为300。

In this case, I am trying to find the sum of unique articles, but only once in case of duplicates. 在这种情况下,我试图找到唯一文章的总和,但只有一次重复。 So, in the above example, I need the sum as A (only once), B, C and D - which comes to 300 + 100 + 300 + 200 = 900 因此,在上面的例子中,我需要总和为A(仅一次),B,C和D - 来自300 + 100 + 300 + 200 = 900

I found a COUNTIF formula but this only sums articles which do not have any duplicates (ie B, C and D) 我找到了一个COUNTIF公式,但这只是对没有任何重复的文章(即B,C和D)的总结

{=SUM(IF(COUNTIF(A:A, A:A) = 1, B:B, 0))}

Am I barking up the wrong tree with COUNTIFs? 我用COUNTIFs咆哮着错误的树吗?

You were close, and COUNTIF is the right way to go. 你很亲密, COUNTIF是正确的方法。 Try this: 试试这个:

=SUMPRODUCT(B1:B6/COUNTIF(A1:A6,A1:A6))

I replaced SUM with SUMPRODUCT so that you don't have to use Ctrl + Shift + Enter 我用SUMPRODUCT替换了SUM ,因此您不必使用Ctrl + Shift + Enter


在此输入图像描述

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

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