具有平均行的数组公式

问题描述 投票:0回答:1

我在Google表格中有一个公式,该公式正在对一行中的值求平均值...

=AVERAGEIF(A2:L2,"<>0")

简单,对吧?

但是,我无法弄清楚如何使ARRAYFORMULA起作用。

=ARRAYFORMULA(AVERAGEIF(A2:L,"<>0")

该公式仅对范围内的所有单元格取平均值,而不返回每行的平均值。我想念什么?

google-sheets average google-sheets-formula array-formulas google-sheets-query
1个回答
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"))

0

© www.soinside.com 2019 - 2024. All rights reserved.