简体   繁体   English

忽略 excel 中 sumproduct 公式中的非数字值

[英]Ignore non-numeric values in sumproduct formula in excel

I tried to use sumproduct formula, but it doesn't ignore non numeric (text) values.我尝试使用 sumproduct 公式,但它不会忽略非数字(文本)值。

Tried double unary.试过双一元。 But nothing works但没有任何效果

=SUMPRODUCT((A2:A8="TX")*B2:B8)
=SUMPRODUCT(--(A2:A8="TX")*B2:B8)
=SUMPRODUCT((A2:A8="TX")*--B2:B8)
=SUMPRODUCT(--(A2:A8="TX")*--B2:B8)

State   Sales
UT  75
CO  100
TX  125
CO  125
TX  150
TX  a
CO  50

I know sumif can do, but im trying to achieve the same from Sumproduct, coz i need to apply it in larger frame我知道 sumif 可以做到,但我试图从 Sumproduct 中实现相同的效果,因为我需要在更大的框架中应用它

try尝试

=SUMPRODUCT(--(A2:A8="TX"),B2:B8)

在此处输入图像描述

SUMPRODUCT function treats non-number value as zero. SUMPRODUCT function 将非数值视为零。 So, you can directly use B2:B8 as second argument without considering if it a text or number.因此,您可以直接使用B2:B8作为第二个参数,而无需考虑它是文本还是数字。

Try this one试试这个

=SUMPRODUCT((A2:A8="TX")*(ISNUMBER(B2:B8)))

To get the logical values.获取逻辑值。 If you want the result:如果你想要结果:

=SUMPRODUCT((A2:A8="TX")*(ISNUMBER(B2:B8)),B2:B8)

Use ISNUMBER function which will ignore the non numeric value.使用ISNUMBER function 将忽略非数值。

=SUMPRODUCT((A2:A8="TX")*(ISNUMBER(B2:B8)),B2:B8) =SUMPRODUCT((A2:A8="TX")*(ISNUMBER(B2:B8)),B2:B8)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM