在Excel中对日期范围内的单元格进行计数,但仅限于大于其上方的单元格

时间:2018-07-20 16:57:11

标签: excel

我有一个电子表格,显示每周增加和减少的百分比。我想计算在给定年份中,一周的数字比之前一周增加的次数,而且前提是前一周的增长至少为2%。

例如,在以下电子表格中,2010年的计数应为1:

Date         Increase/Decrease %
12/28/2009   -3.1%
1/4/2010     1.2%
1/11/2010    2.0%
1/18/2010    2.1% (this is the one that should be counted)
1/25/2010    1.9% 
2/1/2010     2.5% (don't count because previous week did not meet 2% threshold)

这是我用来计算满足百分比增长的次数的公式,但是我不确定如何添加下周必须超过前一周的条件。

=COUNTIFS($B$2:$B$7,">"&.02,$A$2:$A$7,">"&"12/31/2009,$A$2:$A$7,"<"&"1/1/2011")

1 个答案:

答案 0 :(得分:2)

=SUMPRODUCT(-(B3:B7>B2:B6),-(B2:B6>=0.02),-(A3:A7>DATE(2009,12,31)),-(A3:A7<DATE(2011,1,1)))

或者借助BigBen的见识:

=SUMPRODUCT((B3:B7>B2:B6)*(B2:B6>=0.02)*(YEAR(A3:A7)=2010))