我在Google表格中有一个公式,该公式正在对一行中的值求平均值...
=AVERAGEIF(A2:L2,"<>0")
简单,对吧?
但是,我无法弄清楚如何使ARRAYFORMULA
起作用。
=ARRAYFORMULA(AVERAGEIF(A2:L,"<>0")
该公式仅对范围内的所有单元格取平均值,而不返回每行的平均值。我想念什么?
你很近。尝试:
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(A2:L),
"select "&TEXTJOIN(",", 1, IF(LEN(A2:A),
"avg(Col"&ROW(A2:A)-ROW(A2)+1&")", ))&"")),
"select Col2"))
然后添加<>0
您需要:
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(A2:L),
"select "&TEXTJOIN(",", 1, IF(LEN(A2:A),
"avg(Col"&ROW(A2:A)-ROW(A2)+1&")", ))&
"where "&TEXTJOIN(" and ", 1, IF(LEN(A2:A),
"not Col"&ROW(A2:A)-ROW(A2)+1&"=0", ))&"")),
"select Col2"))