Excel: COUNTIF function treats 'less than' character as an operator

蹲街弑〆低调 提交于 2020-01-03 17:01:41

问题


Pre-read note: I'm using LibreOffice rather than Excel, but most functions should apply to both.

I'm making a spreadsheet where I have a bunch of data, and for every property (such as # of employees or a name) I need a function that calculates how many rows contain each distinct value.
I already have the distinct values extracted, and now I'm using the following function to calculate how many rows have each value: =COUNTIF(start:end;value). (Note that the semicolon is LibreOffice's way of separating parameters, as opposed to Excel's comma.)

Now, my problem is that I have some rows that can have values such as "< 50". Using the COUNTIF function, it seems that the '<' is treated as a 'less than' operator, rather than as a text character. Therefore, if the cell I'm trying to match the column against has the value "< 50", I end up with a value 0 as result of the formula. How can I get the COUNTIF to treat the less-than sign as a text character? Or is there another function I should use here?


回答1:


In Excel you could use SUMPRODUCT, i.e.

=SUMPRODUCT((start:end=value)+0)

The direct comparison using = will do an exact comparison and isn't confused by < or > like COUNTIF




回答2:


=COUNTIF(A:A,"=< 50")

Works for me in Excel 2007



来源:https://stackoverflow.com/questions/19029970/excel-countif-function-treats-less-than-character-as-an-operator

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