使用 Google Sheets 上的 ArrayFormula 逐行迭代 COUNTIF [英] iterate row by row COUNTIF using ArrayFormula on Google Sheets

查看:24
本文介绍了使用 Google Sheets 上的 ArrayFormula 逐行迭代 COUNTIF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试迭代一个 COUNTIF 公式,该公式计算每行中包含大于 4 的数字的单元格数.我正在尝试使用 ArrayFormula 来执行此操作,但它不起作用.

I am trying to iterate a COUNTIF formula that counts the number of cells in each row containing numbers greater than 4. I am trying to use ArrayFormula to do this but it isn't working.

不幸的是,它计算了整个范围 B2:G39 中与条件匹配的所有单元格,导致在 K 列的每行中输入 26 个,而不是逐行计数,即在 B2:G2 中输入的单元格数 >4,在 K2 中输入,B3中>4的单元格数量:K3中输入的G3

Unfortunately it counts ALL the cells matching the condition across the entire range B2:G39 resulting in 26 being entered in each row of column K rather than row by row count i.e. number of cells >4 in B2:G2 entered in K2, number of cells >4 in B3:G3 entered in K3

这是公式

=ARRAY_CONSTRAIN(arrayformula( if( row(H:H)=1, "Number of cells >4",COUNTIF(A2:G39,">4"))),39,1)

这是一个电子表格,其中包括示例数据和我的公式

Here is a spreadsheet that includes sample data and my formula

推荐答案

尝试在单元格 K2 中输入:

Try entering this in cell K2:

=ARRAYFORMULA(IF(ISBLANK(A2:A),IFERROR(1/0),MMULT(SIGN(A2:G>4),SIGN(TRANSPOSE(A2:G2)))))

通过将您的数据转化为矩阵形式,您可以使用 MMULTSIGN 函数与 ARRAYFORMULA 一起实现对您的行的条件计数正在寻找.

By putting your data into matrix form, you can use the MMULT and SIGN functions with ARRAYFORMULA to achieve the conditional count over rows you're looking for.

这篇关于使用 Google Sheets 上的 ArrayFormula 逐行迭代 COUNTIF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆