如果某个范围的单元格不满足此要求,则SUMPRODUCT((range = {"this";" that}} *(其他条件))返回N/A.

编程入门 行业动态 更新时间:2024-10-11 17:24:52
本文介绍了如果某个范围的单元格不满足此要求,则SUMPRODUCT((range = {"this";" that}} *(其他条件))返回N/A.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

数据集:

A|B 1|a 2|b 3|c

公式:

=SUMPRODUCT((B1:B3={"a";"b"}))

sumproduct返回值NA不存在.我不明白为什么.我希望它返回2.

The sumproduct return NA there. I don't get why. I want it to return 2.

如果我将c添加到条件中,它将正确返回3.

If I add c to the condition it correctly returns 3.

我想念什么?

推荐答案

您正在将大小为1x3的数组与大小为1x2的数组进行比较. (如果比较两个垂直数组,它们的大小必须相同.这就是为什么在公式中添加"c"时解决此问题的原因.)

You are comparing an array of size 1x3 to an array of size 1x2 which is not allowed. (If you compare two vertical arrays, they must be the same size. This is why the problem is fixed when you add "c" to the formula.)

您需要将1x3数组与 2x1 数组进行比较.

You need to compare a 1x3 array to a 2x1 array.

此表达式:

B1:B3={"a";"b"}

返回:

{TRUE;TRUE;#N/A}

SUMPRODUCT无法处理逻辑(TRUE/FALSE)值,因此必须加0,乘以1或执行双负运算符才能更改为数值数组.

SUMPRODUCT cannot handle logical (TRUE/FALSE) values so you must add 0, multiply by 1, or perform double negative operator to change to an array of numerical values.

所以...这个:

--(B1:B3={"a";"b"})

返回:

{1;1;#N/A}

对此执行SUMPRODUCT仍将返回#N/A,因为数组包含#N/A.

Performing SUMPRODUCT on this will still return #N/A since the array contains #N/A.

但是,如果您这样做:(请注意用逗号代替分号)

But if you do this: (Note the comma instead of semicolon)

B1:B3={"a","b"}

现在,您得到了:

{TRUE,FALSE;FALSE,TRUE;FALSE,FALSE}

请注意,这将返回2x3数组.

Note this returns a 2x3 array.

执行双负运算符,您会得到:

Perform double negative operator and you get this:

{1,0;0,1;0,0}

现在执行SUMPRODUCT将返回2,如您所愿.

Now performing SUMPRODUCT will return 2, as you expect.

您需要的最终公式是:

= SUMPRODUCT(--(B1:B3 = {"a","b"}))

更多推荐

如果某个范围的单元格不满足此要求,则SUMPRODUCT((range = {"this";" that}} *(其他条件))返回

本文发布于:2023-10-28 01:23:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1535084.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不满足   单元格   条件   SUMPRODUCT   quot

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!