简体   繁体   English

SUMIF值大于上一列中的值

[英]SUMIF Value is Greater Than Value in Previous Column

Is there a way to use SUMIF to sum values in a column when they are greater than the value in the same row in the previous column? 当值大于上一列同一行中的值时,是否可以使用SUMIF对一列中的值求和? ie the sum of B2, B4, and B6 in the picture 即图片中B2,B4和B6之和

Using an array formula: 使用数组公式:

=SUM(IF($B$2:$B$6>$A$2:$A$6,$B$2:$B$6))

Be sure to press Ctrl+Shift+Enter when you exit cell edit mode instead of only Enter 退出单元格编辑模式时,请务必按Ctrl+Shift+Enter ,而不仅仅是Enter

I would use an array because I'm too lazy to figure out a non-array solution: 我会使用数组,因为我懒得找出一个非数组的解决方案:

{=SUM(If(B:B>A:A,B:B,0))}

Limit the ranges as necessary to increase performance. 根据需要限制范围以提高性能。

The main focus here is to don't hardcode each cell... 这里的主要重点是不要对每个单元格进行硬编码...

This can be achieved by: 这可以通过以下方式实现:

  1. Using a combination of sum and if in an array operation 在数组操作中使用总和和组合

    {=SUM(IF(B:B>A:A;1;0))}

OR 要么

  1. Creating another column and performing a sum: 创建另一列并执行求和:

In column C put this function in each row: 在C列中,将此函数放在每一行中:

=IF(B2>A2;B2;0)

Then on a single cell (lets say D2 ), place this formula: 然后在单个单元格上(让我们说D2 ),放置以下公式:

=SUM(C:C)

Ie: 即:

表格1

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

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