Excel array countif formula

有些话、适合烂在心里 提交于 2020-01-02 07:39:39

问题


I want to use COUNTIF function to evaluate how many items out of 2,0,0,5 are greater than 2? In Countif function, first argument is range and second is criteria. I have tried the below formula. Even tried using Ctrl+Shift+Enter at the end to evaluate. But doesn't seem to work.

=COUNTIF({"2","0","0","5"},">2")

回答1:


COUNTIF doesn't accept array constants (as far as I know). Try this:

=SUMPRODUCT(--({2,0,0,5}>2))

You could also create a countif-style formula like this (the combination ctrl+shift+enter):

=COUNT(IF({2,0,0,5}>2,1,""))



回答2:


Recommended reading: Array vs Range

Some functions like Offset, SumIf, CountIf, SumIfs, and CountIfs are designed to operate only on (multi-cell) range objects. Sum, SumProduct, Frequency, Linest, lookup functions, etc. take both range and array objects.

Array means: {2,0,0,5}

Range means:

To use countif, you have to use range in cells, defining the array in the formula on the go will not work.

=COUNTIF(A1:A4,">"&2)


来源:https://stackoverflow.com/questions/48095934/excel-array-countif-formula

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