OpenOffice.org Calc SUMIF 语句
如果 A 列中的相应单元格位于 (10; 20] 中,我试图对 C2:C2000 中的所有单元格求和,但我遇到了条件问题。
我尝试过类似 =SUMIF(A2 :A2000, AND(">10","<=20"), C2:C2000)
,但返回 0,这是不正确的
可以
[编辑]
使用 =。 SUMIF(A2:A2000, ">10", C2:C2000) - SUMIF(A2:A2000, ">20", C2:C2000)
但这并不完全是我想要的。
I'm trying to sum all cells in C2:C2000 if the corresponding cell in column A is in (10; 20], but I'm having problems with the condition.
I've tried something like =SUMIF(A2:A2000, AND(">10","<=20"), C2:C2000)
, but that returns 0 which is incorrect.
Thanks.
[edit]
It is possible to use =SUMIF(A2:A2000, ">10", C2:C2000) - SUMIF(A2:A2000, ">20", C2:C2000)
but that's not exactly what I'm looking for.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决复杂条件限制的简单方法是使用另一列作为“局部变量” - 使 D 列成为条件的结果(AND(等)),如果您想减少屏幕混乱,则隐藏它,然后使用D2:D2000 作为 SUMIF 的 if 部分。
编辑以添加备用选项:
http://support.microsoft.com/kb/275165
使用 Sum (if( .. )) 代替 SUMIF,并使用乘积和和代替 AND 和 OR。
就我个人而言,我认为使用中间列更容易遵循和维护。
The easy way to get around the complex conditions limitation is to use another column as a 'local variable' - make column D the result of your condition (AND(etc)), hide it if you want to have less screen clutter, and use D2:D2000 as the if part of the SUMIF.
edited to add alternate option:
http://support.microsoft.com/kb/275165
use Sum(if( .. )) instead of SUMIF, and use products and sums instead of ANDS and ORs.
Personally, I think using an intermediate column is easier to follow and maintain.
OpenOffice 中一个相对优雅的解决方案是使用 Sumproduct——它将两个数组相乘。对 Sumproduct 进行连续的真值测试(我认为它返回布尔值数组)。像这样的事情:
我从这里得到这个:
http ://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=28585
在 OpenOffice 中测试 - 我不知道 Excel 中是否有等效项。抱歉,我没有可供测试的副本。
A relatively elegant solution in OpenOffice is to use Sumproduct -- which multiplies together two arrays. Feed Sumproduct with successive truth tests on the range (which return an array of booleans, I think). Something like this:
I got this from here:
http://user.services.openoffice.org/en/forum/viewtopic.php?f=9&t=28585
Tested in OpenOffice -- I have no idea if there's an equivalent in Excel. Sorry, I don't have a copy to test on.