+ Reply to Thread
Results 1 to 29 of 29

countif formula for multiple conditions in the same coloumn

  1. #1
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    countif formula for multiple conditions in the same coloumn

    Hi All,

    I want to count the number of "a"s and "b"s in column 1 if the relevant column 2 value is equal to "aa" or "bb". please refer below data set. Answer should be 4.

    Here is the formula i used for this,

    =SUMPRODUCT(COUNTIFS(E16:E25,{"aa","bb"},C16:C25,OR("a","b")))

    a - aa
    d - aa
    b - bb
    b - aa
    c - cc
    b - dd
    a - ee
    Last edited by kazun909; 09-12-2014 at 03:14 AM.

  2. #2
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Hi.

    =SUM(COUNTIFS(E16:E25,{"aa","bb"},C16:C25,{"a";"b"}))

    See here for an explanation on this syntax if you're interested:

    http://excelxor.com/2014/09/02/count...iteria_ranges/

    Regards
    Click * below if this answer helped

    Advanced Excel Techniques: http://excelxor.com/

  3. #3
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: countif formula for multiple conditions in the same coloumn

    as per above data the answer will be 3
    Samba

    Say thanks to those who have helped you by clicking Add Reputation star.

  4. #4
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    4 as result? why?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    gives 3 as result and XOR LX's formula gives 2 as result.
    Regards

    Fotis.

    -This is my Greek whisper to Europe.

    --Remember, saying thanks only takes a second or two. Click the little star * below, to give some Rep if you think an answer deserves it.

    Advanced Excel Techniques: http://excelxor.com/

    --KISS(Keep it simple Stupid)

    --Bring them back.

    ---See about Acropolis of Athens.

    --Visit Greece.

  5. #5
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: countif formula for multiple conditions in the same coloumn

    Please Login or Register  to view this content.
    Another working formula, which give result 3.
    -If the problem is solved, please mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved".

    -Always upload a workbook before start your question
    To attach a file, push the button with the paperclip (or scroll down to the Manage Attachments button), browse to the required file, and then push the Upload button.

    +++ If my answer(s) helped you, please add me reputation by click on * +++

  6. #6
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    Thanks a lot

  7. #7
    Forum Guru samba_ravi's Avatar
    Join Date
    07-26-2011
    Location
    Hyderabad, India
    MS-Off Ver
    Excel 2021
    Posts
    8,914

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    4 as result? why?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    gives 3 as result and XOR LX's formula gives 2 as result.
    XOR LX's will also giving the same result as your formula i,e 3

  8. #8
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    Hi all,

    can we perform the same thing if the column 1 data is a date and it should be within 2 days before than today's date.

    9/11/2014 - aa
    9/11/2014 - aa
    9/11/2014 - bb
    9/5/2014 - aa
    9/10/2014 - cc
    9/10/2014 - dd
    9/8/2014 - ee


    I tried below formula but it didn't work

    =SUM(COUNTIFS(E16:E25,{"aa","bb"},C16:C25,{today()-24/24;today()-48/24}))

  9. #9
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    Thanks A lot

  10. #10
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    @nflsales

    So in that case it's obviously that i am missing something. What is this?
    Attached Files Attached Files

  11. #11
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    Please help

  12. #12
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    @nflsales

    So in that case it's obviously that i am missing something. What is this?
    =SUM(COUNTIFS(E16:E25,{"aa","bb"},C16:C25,{"a";"b"}))

    instead of ;

  13. #13
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    Yeah as per this answer is 3, this works for me

    =SUM(COUNTIFS(F30:F39,{"aa","bb"},E30:E39,{"a";"b"}))

  14. #14
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    can anyone please help me on this???

    Hi all,

    can we perform the same thing if the column 1 data is a date and it should be within 2 days before than today's date.

    9/11/2014 - aa
    9/11/2014 - aa
    9/11/2014 - bb
    9/5/2014 - aa
    9/10/2014 - cc
    9/10/2014 - dd
    9/8/2014 - ee


    I tried below formula but it didn't work

    =SUM(COUNTIFS(E16:E25,{"aa","bb"},C16:C25,{today()-24/24;today()-48/24}))

  15. #15
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: countif formula for multiple conditions in the same coloumn

    Hi kazun909, you mean this?
    Please Login or Register  to view this content.

  16. #16
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    4 as result? why?
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    gives 3 as result and XOR LX's formula gives 2 as result.
    Not sure I understand, Fotis.

    My formula also gives 3. Did you copy it correctly?

    Edit: just seen wenqq3's post #12. Shame on you, Fotis, for not copying the formula correctly! You should read the post in my blog to understand this syntax business!



    Regards

  17. #17
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    As ALL of you say this, i have no reason to don't believe it(also when i saw carefully it, i know how it is works and also i know that you test your formulas before you post ), BUT i am very curious why does not gives me correct result..

    Take a look to my attachment in post#10.

  18. #18
    Registered User
    Join Date
    09-11-2014
    Location
    Colombo, Sri Lanka
    MS-Off Ver
    2013
    Posts
    12

    Re: countif formula for multiple conditions in the same coloumn

    thanks that worked

  19. #19
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    As ALL of you say this, i have no reason to don't believe it(also when i saw carefully it, i know how it is works and also i know that you test your formulas before you post ), BUT i am very curious why does not gives me correct result..

    Take a look to my attachment in post#10.
    What doesn't give the correct result? I don't understand.

    In that attachment you did not copy my formula correctly, as wenqq3 pointed out in post #12.

    Do you mean you don't understand why it doesn't work if you have semi-colons in both arrays? If so, then like I said, I would suggest you have a read of my explanation here!

    http://excelxor.com/2014/09/02/count...iteria_ranges/

    Cheers

  20. #20
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    Do you see the formula in F2 in my attachment?? Gives 2 as result..

    I say again that i don't have any objection that formula works.

    My goal is to find out why does not works for me.

  21. #21
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    Do you see the formula in F2 in my attachment?? Gives 2 as result..

    I say again that i don't have any objection that formula works.

    My goal is to find out why does not works for me.
    The explanation is in the link I sent you.

    If you don't want to read all that then I understand. I could try to explain again here in this post but it would take some space and time and since I've already written it there it may be best if you spend some time reading that!

    Cheers

  22. #22
    Valued Forum Contributor wenqq3's Avatar
    Join Date
    04-01-2013
    Location
    Malaysia
    MS-Off Ver
    Excel 2003
    Posts
    868

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    Do you see the formula in F2 in my attachment?? Gives 2 as result..

    I say again that i don't have any objection that formula works.

    My goal is to find out why does not works for me.
    F2 formula have typo.

    =SUM(COUNTIFS(B1:B7,{"aa";"bb"},A1:A7,{"a";"b"}))

    Where XOR LX is
    =SUM(COUNTIFS(B1:B7,{"aa","bb"},A1:A7,{"a";"b"}))

  23. #23
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    ...I've already written it there it may be best if you spend some time reading that!
    As you can see i have(since many days now) a link of your site in my Signature. So no need of such suggestions. I have read it again and again and as i believe that i am not an idiot not even an Excel idiot..) i try to say that formula works ONLY if i put in both ARRAYS semi colons(we use semi colons in Greece as separators. Not comma) and gives a result of 2. Trying to use comma in one ARRAY and semi colon in the other, gives me an error.

    I assume that it's something from my local settings...

    Thank you for your replies.

    @ wenqq3

    Thank you very much for your explanations. I really appreciate this.

  24. #24
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    As you can see i have(since many days now) a link of your site in my Signature.
    Very kind of you!

    Quote Originally Posted by Fotis1991 View Post
    Trying to use comma in one ARRAY and semi colon in the other, gives me an error.
    I assume that it's something from my local settings...
    I recall that for the Excel version you're using you do have a different syntax for array constants, though I thought that only applied to arrays containg numerical values.

    I can't remember the exact syntax, but I think "\" is used in those cases. Am I right?

    Regards

  25. #25
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by XOR LX View Post
    Very kind of you!

    I can't remember the exact syntax, but I think "\" is used in those cases. Am I right?

    Regards
    Yes you are! Thank you.So the Greek version of your formula is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

  26. #26
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    Yes you are! Thank you.So the Greek version of your formula is:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Great! Remember it!!

  27. #27
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    I'll do my best...My age sometimes does not helps..........

  28. #28
    Forum Expert XOR LX's Avatar
    Join Date
    04-18-2013
    Location
    Turin, Italy
    MS-Off Ver
    Office 365
    Posts
    7,742

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by Fotis1991 View Post
    I'll do my best...My age sometimes does not helps..........
    I thought Greeks were eternally youthful?

  29. #29
    Forum Expert Fotis1991's Avatar
    Join Date
    10-11-2011
    Location
    Athens(The homeland of the Democracy!). Greece
    MS-Off Ver
    Excel 1997!&2003 & 2007&2010
    Posts
    13,744

    Re: countif formula for multiple conditions in the same coloumn

    Quote Originally Posted by XOR LX View Post
    I thought Greeks were eternally youthful?
    Greeks were eternally youthful!

    I doubt if we are any more........

    Difficult situations..They f...@@@ us every day......

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] Using multiple conditions in formula like countif(), sumif()
    By 0-0 Wai Wai ^-^ in forum Excel General
    Replies: 14
    Last Post: 11-10-2005, 04:10 PM
  2. COUNTIF - multiple conditions
    By allphin in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-18-2005, 12:05 PM
  3. Multiple conditions on a countif
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 01:05 AM
  4. [SOLVED] Multiple conditions on a countif
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10:05 PM
  5. Multiple conditions on a countif
    By Mr Mike in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 07-29-2005, 11:05 PM

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