Search code examples
excelexcel-formulaexcel-2010excel-2007

how to count the number of values in an column column in excel


I have a column which has monthly income of persons with data like <50,000 , 50,000 to 1,00,000 & so on. I want to count the number of each occurrences of <50,000 in that particular column. i tried using =COUNTIF(X2:X123,"<50,000") but its giving me 0 every time.

data in table looks like this: <50,000 <50,000 <50,000 50,000- 1,50,000 <50,000 <50,000


Solution

  • Eliminate the "," from your formula. With that comma in the "50,000", Excel reads it as text, not a number.

    Edit based on clarification - to count the number of times that a text string appears, you need to use this:

    =Countif(A1:A2,"=asdf")
    

    Or alternatively just

    =Countif(A1:A2,"asdf")
    

    The problem here is that when excel reads "<50000" it actually thinks you want to do a value comparison. After testing see now that "<50,000" actually does properly convert "50,000" to a number. I assume this is because Excel normally takes a string like 'OPERATER_NUMBER' and breaks off the operater and the number part of a string, and then converts that string to a number. So, the comma is properly eliminated.

    So if you want to see how many times the string "50,000" appears, use this: =Countif(A1:A2,"="&"<50,000")

    Actually to be clear, you could also just do =Countif(A1:A2,"=<50,000")

    But when I read it this way, I read it as "Equal to or lesser than 50,000". Though excel appears to know what to do with it. In any case, I think separating the "=" from the "<50,000" is more clear.