Excel 如果满足某些条件,用数字计数细胞
Excel Count cells with number if certain conditions are met
我想找出第 NO2 列(例如)中包含数字的单元格的百分比,仅考虑在某个小时内某个月份的单元格 - 例如,有多少单元格包含数字一月份每天第一个小时的 NO2 列。
我一直在尝试1 - COUNTIF(condition,"*")/COUNTA(condition)
,但是我在写条件部分时遇到了问题。
条件(考虑三个月)。它给了我 $VALUE!如果我尝试将其放入 COUNTIF
会出错
IF($C:$C85="January",
IF($B:$B85="1:00",$E:$E85,""),
IF($C:$C85="February",
IF($B:$B85="1:00",'$E:$E85,""),
IF($C:$C85="December,
IF($B:$B85="1:00",$E:$E85,"")
尝试使用 =SUMPRODUCT()
:
=SUMPRODUCT(--(A:A="January"), --(B:B=TIMEVALUE("1:00")), --(ISNUMBER(C:C)))
你要替换的地方:
A:A
加上你的月份列
B:B
加上你的时间栏
C:C
与您的 NO2 列
加入'OR Logic'
如果您想使用 OR 逻辑,您可以简单地 "add" 使条件看起来像
--((A:A="January")+(A:A="February"))
.
=SUMPRODUCT(--((A:A="January")+(A:A="February")), --(B:B=TIMEVALUE("1:00")),
--(ISNUMBER(C:C)))
所以这表示 A 列可以 January
或 February
, and B列的时间值为1:00
,and C列为数值。
这实际上创建了三个数组 - 每个条件 1 个。它看起来像这样:
{"January", "January", "January", "February"}
{"1:00 AM", "1:00 AM", "2:00 AM", "1:00 AM" }
{ 1.0, 1.3, "text", 4 }
它将这些转换成True/False
{True, True, True, True}
{True, True,False, True}
{True, True,False, True}
^^^^ ^^^^ ^^^^ << Counts the number where ALL are 'True'
当每个 'indexes' 都 return 为真时,它被添加到你的函数中。
If these arrays do not have the same length, then your SUMPRODUCT()
function will return an error.
{True, True, True, True}
{True, True,False, True}
{True, True,False}
^^^^ ^^^^ *ERR << Returns error as the last array was smaller
我想找出第 NO2 列(例如)中包含数字的单元格的百分比,仅考虑在某个小时内某个月份的单元格 - 例如,有多少单元格包含数字一月份每天第一个小时的 NO2 列。
我一直在尝试1 - COUNTIF(condition,"*")/COUNTA(condition)
,但是我在写条件部分时遇到了问题。
条件(考虑三个月)。它给了我 $VALUE!如果我尝试将其放入 COUNTIF
IF($C:$C85="January",
IF($B:$B85="1:00",$E:$E85,""),
IF($C:$C85="February",
IF($B:$B85="1:00",'$E:$E85,""),
IF($C:$C85="December,
IF($B:$B85="1:00",$E:$E85,"")
尝试使用 =SUMPRODUCT()
:
=SUMPRODUCT(--(A:A="January"), --(B:B=TIMEVALUE("1:00")), --(ISNUMBER(C:C)))
你要替换的地方:
A:A
加上你的月份列B:B
加上你的时间栏C:C
与您的 NO2 列
加入'OR Logic'
如果您想使用 OR 逻辑,您可以简单地 "add" 使条件看起来像
--((A:A="January")+(A:A="February"))
.
=SUMPRODUCT(--((A:A="January")+(A:A="February")), --(B:B=TIMEVALUE("1:00")),
--(ISNUMBER(C:C)))
所以这表示 A 列可以 January
或 February
, and B列的时间值为1:00
,and C列为数值。
这实际上创建了三个数组 - 每个条件 1 个。它看起来像这样:
{"January", "January", "January", "February"}
{"1:00 AM", "1:00 AM", "2:00 AM", "1:00 AM" }
{ 1.0, 1.3, "text", 4 }
它将这些转换成True/False
{True, True, True, True}
{True, True,False, True}
{True, True,False, True}
^^^^ ^^^^ ^^^^ << Counts the number where ALL are 'True'
当每个 'indexes' 都 return 为真时,它被添加到你的函数中。
If these arrays do not have the same length, then your
SUMPRODUCT()
function will return an error.{True, True, True, True} {True, True,False, True} {True, True,False} ^^^^ ^^^^ *ERR << Returns error as the last array was smaller