+ Reply to Thread
Results 1 to 5 of 5

Excel 2007 : Countif with an or condition

  1. #1
    Registered User
    Join Date
    08-09-2010
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    26

    Countif with an or condition

    Hello everyone,

    I have a question reguarding a small project im working on. I have weather data from our local stats site and it give me hourly data between jan 2010 to may 20 2011.
    The file contains some data in a colum that looks like the following:


    cloudy
    cloudy and rainy
    fog and rainy
    fog
    haze
    cloudy and snow
    clear
    etc... (another several thousand lines)


    Now what I would like to do is determine how many time something other then clear comes up. For example I would like to:

    COUNTIF(A1:A50,OR("*rain*","*cloudy*",etc))

    Now the above OR is not working, if i remove the OR and use a single criteria I get the proper result, but when i add the OR and another criteria as shown above i get 0 as a result. Notice that some lines of data contain both key words cloudy and rain so this is the reason i want to use the OR, i dont want to count both instances just one for that particular hour.

    Please advise, thank you for your help.

    Matt

  2. #2
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Countif with an or condition

    Try this:

    =SUMPRODUCT(COUNTIF(A1:A50, B1:B10))

    where in A column is your data, and in B column your criterias

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: Countif with an or condition

    .....but that will double count rows that contain both "rain" and "cloudy" if you use wildcards with the criteria. Can't you just count lines which explicitly aren't "Clear" e.g.

    =COUNTIF(A1:A50,"<>Clear")

    or

    =COUNTIF(A1:A50,"<>*Clear*")
    Audere est facere

  4. #4
    Registered User
    Join Date
    08-09-2010
    Location
    toronto
    MS-Off Ver
    Excel 2003
    Posts
    26

    Re: Countif with an or condition

    I could count clear but there are more criteria then the ones I listed so I do need to do something similar to my first post without the double counting of lines as noted above.
    I assume countif and the or operations do not work together?
    Thanks in advance

  5. #5
    Forum Moderator zbor's Avatar
    Join Date
    02-10-2009
    Location
    Croatia
    MS-Off Ver
    365 ProPlus
    Posts
    15,592

    Re: Countif with an or condition

    Check my above solution...
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1