[英]SUMIF date in column B is less than date in column C
I have a list of values in Column A and want to sum these values where the date in Column B is less than Column C. 我在A列中有一个值列表,并且想对B列中的日期小于C列中的这些值求和。
In this example the correct value would be 2100
. 在此示例中,正确值为
2100
。
I have previously had to complete this task with reference to a single date (eg the date contained in C3) and used the formula: 我以前不得不参考单个日期(例如,C3中包含的日期)完成此任务,并使用以下公式:
=SUMIF(B2:B11,"<="&C3,A2:A11)
However in this instance I need each date in B to be less than or equal to the date in C. I have tried: 但是在这种情况下,我需要B中的每个日期都小于或等于C中的日期。
=SUMIF(B2:B11,"<="&C2:C11,A2:A11)
But I get a value of 0
. 但是我得到的值为
0
。 Any ideas? 有任何想法吗?
Option A - Helper column 选项A-助手列
The simplest approach for any scenario requiring working out on a row by row basis whether to do something or other - be it a sum, Lookup, etc - , is to use a 'helper' column alongside your data that uses a formula to work out whether it should or should not be included, typically returning 'True' if to be included. 对于需要逐行计算是否要做某事(例如求和,查找等)的任何情况,最简单的方法是在数据旁边使用“帮助器”列,该列使用公式进行计算是否应该包括在内,如果要包括在内,通常会返回“ True”。
With your data layout, in column D add a calculation that works out the difference and therefore whether the row should be included, such as: 使用数据布局,在D列中添加一个计算出差异的计算,并因此计算出是否应包括该行,例如:
=C2-B2
or =C2>B2
dragged down =C2-B2
或=C2>B2
向下拖动
The SUMIFS calc then becomes =SUMIFS(A2:A11,D2:D11,">0")
or, for the general case with more complex criteria, =SUMIFS(A2:A11,D2:D11,TRUE)
然后,SUMIFS calc变为
=SUMIFS(A2:A11,D2:D11,">0")
或者对于具有更复杂条件的一般情况, =SUMIFS(A2:A11,D2:D11,TRUE)
This approach is excellent if you have a large number of complex criteria, perhaps varying by rows or perhaps requiring multiple AND()
OR()
and other logical evaluations (is a product ID x and is a customer ID y and is the value > z and is the days between purchase order being submitted and goods received more than 30 days) etc, to determine whether a row should be included in some further function. 如果您有大量复杂的标准,可能因行而异,或者可能需要多个
AND()
OR()
和其他逻辑求值(是产品ID x,是客户ID y,且值> z以及提交订单和收到货物之间的天数超过30天)等,以确定是否应在其他功能中添加一行。
Option B - Array formula 选项B-数组公式
Alternatively, you can avoid the need for a working column by using an array formula that performs the comparisons in the formula. 或者,您可以通过使用在公式中执行比较的数组公式来避免需要工作列。 Under the data above this would be like:
在上面的数据下,这将是:
=SUM(IF(B2:B11<C2:C11,A2:A11,0))
entered with Ctrl + Shift + Enter 用Ctrl + Shift + Enter输入
=SUM(IF(B2:B11<C2:C11,A2:A11,0))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.