[英]Use result of IF formula in single cell Excel array formula
I have a column J
with the below array formula: 我有一个
J
列,其中包含以下数组公式:
=IF(ISNUMBER($H$5:$H$263), $H$5:$H$263, $I$5:$I$263)
And a cell on a summary line that references the contents of that column: 汇总行上引用该列内容的单元格:
=SUMIF($J$5:$J$267,"<"&(TODAY()+365), $L$5:$L$263)
The above gives me the result I want, but I am wanting to consolidate this down into a single formula. 上面给出了我想要的结果,但是我想将其合并为一个公式。
I have tried the below: 我尝试了以下方法:
=SUMIF(IF(ISNUMBER($H$5:$H$263), $H$5:$H$263, $I$5:$I$263),"<"&(TODAY()+365), $L$5:$L$263)
But it ends up only summing the contents of the left side of the IF
但是最后只求和了
IF
左侧的内容
So the below can get me what I want: 因此,以下内容可以为我提供所需的信息:
=SUMIF(IF(ISNUMBER($H$5:$H$263), $I$5:$I$263, $H$5:$H$263),"<"&(TODAY()+365), $L$5:$L$263) + SUMIF(IF(ISNUMBER($H$5:$H$263), $H$5:$H$263, $I$5:$I$263),"<"&(TODAY()+365), $L$5:$L$263)
But I'm not sure what I am doing wrong with the first shorter formula. 但是我不确定第一个较短的公式出了什么问题。
Use this array formula: 使用此数组公式:
=SUM(IF(IF(ISNUMBER($H$5:$H$263),$H$5:$H$263,$I$5:$I$263)<TODAY()+365,$L$5:$L$263))
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter when exiting edit mode. 作为数组公式,退出编辑模式时,需要使用Ctrl-Shift-Enter而不是Enter进行确认。 If done correctly then Excel will put
{}
around the formula. 如果操作正确,则Excel会将
{}
放在公式周围。
You can use SUMPRODUCT without the need for CSE: 您可以使用SUMPRODUCT,而无需CSE:
=SUMPRODUCT(((ISNUMBER($H$5:$H$263)*($H$5:$H$263)+(NOT(ISNUMBER($H$5:$H$263)) * ($I$5:$I$263)))<TODAY()+365)*$L$5:$L$263)
I would also recommend the use of EDATE(TODAY(),12)
in place of TODAY()+365
to deal with leap year. 我还建议使用
EDATE(TODAY(),12)
代替TODAY()+365
来处理leap年。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.