iterate row by row COUNTIF using ArrayFormula on Google Sheets

半城伤御伤魂 提交于 2019-11-30 15:40:09

Try entering this in cell K2:

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

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.

Max Makhrov

Sample File

I found that mmult is very slow and may cause your file loading a long time. I suggest using len + join (with a query) instead (speed is not tested):

={"RegexReplace-Len..."; ArrayFormula(LEN(REGEXREPLACE(TRANSPOSE(QUERY(TRANSPOSE(FILTER(--(A2:P>5),A2:A<>"")),,100500)),"[ 0]", "")))}

Also here's a solution by JPV:

=filter(COUNTIF(IF(A2:P>5, ROW(A2:A)), ROW(A2:A)), A2:A<>"")

Change A2:P to your range, A2:A to a key column with no blank cells.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!