+ Reply to Thread
Results 1 to 13 of 13

Counting function with multiple criterias

  1. #1
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Counting function with multiple criterias

    Hi everyone,

    I have a table with 6 columns and I need to count entries in column A, when certain criterias are met. I'll try to attach an example if it works.

    I have two steps for which I need a formula:

    1. I need a formula that counts a project in column A when he finds a certain number in column C which is not on the same row in column E. If he finds e.g. 46982 in column C and E he should not count the project in A

    2. I need a formula that counts a project in column A when he finds a certain number in column C and on the same row finds that number in column E too. (So basically, what Excel doesn't count in 1. it should count here).
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Counting function with multiple criterias

    For step 1

    =COUNTIFS(A:A,A2,C:C,"<>"&E2)

    Step 2

    =COUNTIFS(A:A,A2,C:C,E2)

  3. #3
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Counting function with multiple criterias

    Many thanks for your help.

    However, it is not exactly what I am looking for.

    This works fine if I want to count for every row separately.

    In my case, I want to insert a formula into one cell only and then it should count all the unique project numbers in column A with the criterias in mind.
    Last edited by etaver87; 04-26-2016 at 09:27 AM.

  4. #4
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,216

    Re: Counting function with multiple criterias

    Deleted by JT
    Last edited by JohnTopley; 04-26-2016 at 09:49 AM.

  5. #5
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Counting function with multiple criterias

    OK, this doesn't work exactly as expected. I think I can figure out so that it gives me the sum count of all unique project numbers for a certain number in column C.

    The difficult thing for me is now, however, to make sure, that it doesn't count the four cases for number 46982 where that person is also in the Manager role, i.e. where the number 46982 is also in column E.

    So I first would want the sum count of all unique projects that person is on, e.g. person 46982, and then deduct from that sum count the cases where that person is on both Director and Manager role (four cases here, cf. screenshot)
    Attached Images Attached Images

  6. #6
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Counting function with multiple criterias

    Attached png images don't display correctly on the forum, so we can't see your latest example.

    A couple of things to try and make this work more efficiently.

    Can we add an extra column with some helper formulas if needed?

    How should rows with # unassigned be counted?

  7. #7
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Counting function with multiple criterias

    Yes, absolutely. Some additional formulas, rows, columns are absolutely fine. Many thanks for your help!

  8. #8
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Counting function with multiple criterias

    And the # Unassigned rows, should they be counted or ignored?

  9. #9
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Counting function with multiple criterias

    Fine if they are ignored.

  10. #10
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Counting function with multiple criterias

    Using your sample file from post #1, enter this formula into G2, and autofill down.

    =IF(AND(C2<>"#",C2=E2),A2&"|"&C2,"")

    Then do the same with this formula in H2.

    =IF(AND(C2<>"#",C2<>E2),A2&"|"&C2,"")

    Then use this Array formula to count the number of unique records where columns C and E have the same number

    =SUM(1/COUNTIF(G2:G4219,G2:G4219))-1

    And this one to count the number of unique records where columns C and E have different numbers

    =SUM(1/COUNTIF(H2:H4219,H2:H4219))-1

    Please note that Array Formulas must be confirmed by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. You will know the array is active when you see curly braces { } appear around your formula. If you do not CTRL+SHIFT+ENTER you will get an error or a clearly incorrect answer. In the case of these formulas, if it is not done correctly then you will see a #DIV/0! error.

    I have noticed that the array formulas are a little slow to calculate so will see if I can find an alternative to improve that.

  11. #11
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Counting function with multiple criterias

    That is really helpful, thank you very much! I'm sure you can help me for my next step:

    I would like to know how many projects there are in column A for the director, for example with the number 46982. How many projects is that person on, basically. Is that possible to count from your above computations? Probably it's really obvious but I don't see it right now.

  12. #12
    Registered User
    Join Date
    02-12-2016
    Location
    Zurich, Switzerland
    MS-Off Ver
    MS Office 2013
    Posts
    94

    Re: Counting function with multiple criterias

    That is really helpful, thank you very much! I'm sure you can help me for my next step:

    I would like to know how many projects there are in column A for the director, for example with the number 46982. How many projects is that person on, basically. Is that possible to count from your above computations? Probably it's really obvious but I don't see it right now.

  13. #13
    Forum Expert
    Join Date
    06-08-2012
    Location
    Left the forum!
    MS-Off Ver
    Left the forum!
    Posts
    5,189

    Re: Counting function with multiple criterias

    A helper of =IF(E2=46982,A2,"") would be one way, then use an array formula in the same format as the others to get the count.

    Might be possible with a pivottable if it's set up correctly.

+ 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. Counting only if adjacent rows match with multiple criterias
    By jparve3283 in forum Excel Formulas & Functions
    Replies: 15
    Last Post: 03-22-2016, 05:23 PM
  2. [SOLVED] Counting with a lot of criterias across multiple sheets
    By k.m. in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-29-2015, 03:39 PM
  3. Counting with multiple criterias across multiple sheets
    By k.m. in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-11-2013, 03:40 PM
  4. Replies: 0
    Last Post: 05-05-2013, 05:47 AM
  5. Counting two criterias
    By jleung07 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-12-2012, 07:42 AM
  6. How to use lookup function with multiple criterias?
    By surfol in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 08-27-2009, 03:43 AM
  7. help please : counting iterations based on multiple criterias
    By ccoindy in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-11-2007, 11:40 AM

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