简体   繁体   English

带条件的 Excel sumproduct

[英]Excel sumproduct with condition

I want to SUMPRODUCT to ranges but only if there is no 0.我想 SUMPRODUCT 到范围,但前提是没有 0。

tried =SUMPRODUCT(--(CN12:CN16="<>0");I4:I8) but the results gets 0,尝试=SUMPRODUCT(--(CN12:CN16="<>0");I4:I8)但结果为 0,

i have to ranges: CN12:CN16 and I4:I8, and CN12:CN16 can sometimes contain zeros.我必须设置范围:CN12:CN16 和 I4:I8,CN12:CN16 有时可以包含零。 then i do not want to take that into the calculations and multiply with the value in I4:I8.那么我不想将其纳入计算并乘以 I4:I8 中的值。

Any suggestions任何建议

Use this formula to get the SUMPRODUCT :使用这个公式得到SUMPRODUCT

=SUMPRODUCT(CN12:CN16, I4:I8)

This evaluates AS:这评估 AS:

=CN12*I4 + CN13*I5 + CN14*I6 + CN15*I7 + CN16*I8

So if one of the values equals to 0 that specific product equals to 0, and the rest of the products add to the total.因此,如果其中一个值等于 0,则特定乘积等于 0,其余乘积加到总数中。

Here you have a REFERENCE to evaluate if any of the cells in your range equals with zero.在这里,您有一个REFERENCE来评估您范围内的任何单元格是否等于零。

Do you actually want to use CN12:CN16 values in the calculation or are they simply a criteria range?你真的想在计算中使用 CN12:CN16 值还是它们只是一个标准范围? In SUMPRODUCT you don't need the quotes so this might be what you need -在 SUMPRODUCT 中,您不需要引号,因此这可能是您需要的 -

=SUMPRODUCT(--(CN12:CN16=<>0);I4:I8)

although SUMIF will get you the same thing more easily虽然 SUMIF 会让你更容易得到同样的东西

=SUMIF(CN12:CN16;"<>0";I4:I8)

So solved it like this: =SUMPRODUCT(CN13:CN17;$I4:$I8)/SUMIF(CN13:CN17;"<>0";$I4:$I8)所以这样解决它: =SUMPRODUCT(CN13:CN17;$I4:$I8)/SUMIF(CN13:CN17;"<>0";$I4:$I8)

As some of you wrote SUMPRODUCT gets zero if there is a zero in a list and then i check that list again in the SUMIF when i divided with the I4:I8.正如你们中的一些人写的那样,如果列表中有零,则 SUMPRODUCT 会为零,然后当我除以 I4:I8 时,我会在 SUMIF 中再次检查该列表。 Maybe I was a little unclear in my description of the problem.可能我对问题的描述有点不清楚。

Thanks for your help.谢谢你的帮助。

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

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