Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 553
Lars Avatar asked Sep 26 '13 13:09

Lars


2 Answers

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

Works for me in Excel 2007

enter image description here

like image 97
user2140261 Avatar answered Sep 16 '22 15:09

user2140261


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

like image 30
barry houdini Avatar answered Sep 17 '22 15:09

barry houdini