简体   繁体   English

B列中的SUMIF日期小于C列中的日期

[英]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列中的这些值求和。

Example 例

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.

相关问题 SumIF列a = X AND列b = Y或Z - SumIF column a = X AND column b = Y OR Z excel如果a列中的名称与b列具有相同的日期,则将c列中的所有结果相加 - excel if a name in column a has the same date as column b add together all results in column c 我正在跟踪我的投资 - 如果第 2 列(包含我的贡献)小于第 3 列(投资回报),则返回第 1 列(发生日期) - I am tracking my investments - If column 2 (contains my contribution) is less than column 3 (investment return), return column 1 (date of occurrence) 如何添加一列数字,该数字与小于或等于Today()的日期在同一行? - How do I add a column of numbers which are in the same row as a date that is less than or equal to Today()? SUMIF值大于上一列中的值 - SUMIF Value is Greater Than Value in Previous Column 根据A列中的日期条件在B列中查找重复名称 - Find repeat names in column B based on date criteria in column A Excel如果A列具有相同的值,则在B列中突出显示最大日期 - Excel If column A has same value then highlight max date in column B 为B列中的每个日期填充B列中的时间范围 - fill a range on times in Column B for each date in Column A 获取B列中的第一个/最后一个值,其中A列中的日期为X - Get first / last value in column B where date in column A is X Excel VBA在同一日期在B列中计算B列中的重复项 - Excel VBA count duplicates in Column B within same date in Column A
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM