简体   繁体   English

excel中的求和产品匹配值

[英]Sumproduct matching values in excel

I have two excel tables: 我有两个Excel表:

    A       B       C       D       E
1   John    10              Mark    2
2   Tommy   20              Tommy   3
3   Jane    15              John    4
4                           Kate    2
5                           Jane    1

Is there a function to sumproduct values in colum B with those values in column E which match by name, ie 10*4 + 20*3 + 15*1 ? 是否具有将列B中的值与E列中按名称匹配的值相乘的函数,即10 * 4 + 20 * 3 + 15 * 1?

You can use sumif for this and just sum up the results when you are done: 您可以为此使用sumif ,并在完成后仅对结果进行总结:

=B1 * sumif(D:D, A1, E:E)

Copy that down your sheet, and then add up the totals. 将其复制到工作表中,然后将总数相加。

If you don't want a ton of formulas hanging out on your sheet, you could convert this to a CSE/Array formula: 如果您不希望在工作表上显示大量公式,可以将其转换为CSE / Array公式:

=SUM($B$1:$B$3*SUMIF(D:D, $A$1:$A$3,E:E ))

Just enter that in and hit Ctrl+Shift+Enter to enter it. 只需输入该内容,然后按Ctrl + Shift + Enter即可输入。 It will get curly braces around it, which means it's an Array formula. 它周围会花括号,这意味着它是一个数组公式。

Since you asked about sumproduct, we could use SUMPRODUCT 由于您询问了sumproduct,因此我们可以使用SUMPRODUCT

=SUMPRODUCT(($A$1:$A$5=A1)*$B$1:$B$5)*SUMPRODUCT(($D$1:$D$5=A1)*$E$1:$E$5)

Now that is assuming there are no repeats (all names are unique). 现在假设没有重复(所有名称都是唯一的)。 In the event that names are not unique you will have those numbers added together then multiplied. 如果名称不是唯一的,则将这些数字加在一起然后相乘。

After you apply that to a column and copied down appropriately, lets say F1 to F3, in F5 you could get your final answer using: 将其应用于列并适当地向下复制之后,说F1到F3,在F5中,您可以使用以下命令获得最终答案:

=SUM(F1:F3)

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

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