+ Reply to Thread
Results 1 to 10 of 10

Count number of entries based on multiple criteria

  1. #1
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Count number of entries based on multiple criteria

    Hi guys,

    I've been trying to figure this out but have just about given up. Below is my table:

    excelquery.png

    Basically, in this table, in the 'users for entry' field, I want to count the number of users in the spreadsheet based on the same category and same month. So, for example, for the Yellow category in month 1, we have 3 total entries, however, the count should be 2 because for user abc, there is a duplicate. We want to ignore the duplicate and only count unique values. However, we don't want to delete the duplicate because in the actual table I'm working on, there are many other fields so the full record is not duplicate, just these fields. I am only showing these fields in the image as the criteria is based on these fields only.

    So, how do I achieve the users for entry via a formula?

    Thanks in advance

  2. #2
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count number of entries based on multiple criteria

    Many members are unable to see images in the *.png format.

    If you need to post an image post it in the *.jpg format.

    Even better than posting images... post a SMALL sample file. That way we can test solutions directly in the file with the relevant data.
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  3. #3
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Count number of entries based on multiple criteria

    Hi,

    Many thanks. Attached is the sample file.

    Excel unique values issue.xlsx

    Thanks

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

    Re: Count number of entries based on multiple criteria

    =SUMPRODUCT(($B$4:$B$11=$G4)*($C$4:$C$11=$H4)/COUNTIFS($B$4:$B$11,$B$4:$B$11,$C$4:$C$11,$C$4:$C$11,$D$4:$D$11,$D$4:$D$11))
    Try this formula
    Here $G4 is Category i,e. Yellow and $H4 is Month i,e. 1
    see the attached file
    Attached Files Attached Files
    Samba

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

  5. #5
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count number of entries based on multiple criteria

    Try this...

    Data Range
    B
    C
    D
    E
    3
    category
    month
    user
    users for entry
    4
    yellow
    1
    abc
    2
    5
    red
    1
    yyy
    1
    6
    blue
    1
    zzz
    2
    7
    yellow
    1
    abc
    2
    8
    yellow
    1
    def
    2
    9
    red
    2
    sss
    1
    10
    orange
    2
    ggg
    1
    11
    blue
    1
    ccc
    2


    This array formula** entered in E4 and copied down:

    =SUM(IF(FREQUENCY(IF((B$4:B$11=B4)*(C$4:C$11=C4),MATCH(D$4:D$11,D$4:D$11,0)),ROW(D$4:D$11)-ROW(D$4)+1),1))

    ** array formulas need to be entered using the key
    combination of CTRL,SHIFT,ENTER (not just ENTER).
    Hold down both the CTRL key and the SHIFT key
    then hit ENTER.

  6. #6
    Valued Forum Contributor
    Join Date
    04-27-2015
    Location
    Abu Dhabi, U.A.E
    MS-Off Ver
    Office 365 | 2016
    Posts
    696

    Re: Count number of entries based on multiple criteria

    =if(countifs($b$4:$b$11,b4,$c$4:$c$11,c4)*countif($d$4:$d$11,d4)=1,1,2)

  7. #7
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Count number of entries based on multiple criteria

    Nfl and Tony, many thanks, both your solutions work. however, just one more question, I see that you have used absolute cell referencing $b$4:$b$11 and the same for C and D. however, this table will expand over time and I would like it so that I don't have to change the 11 value every time a new record is added. Is there a way to make it B:B and C:C etc. so it covers new records too? At the moment, I tried to do that but receive #N/A in users for entry field...

    Many thanks again

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count number of entries based on multiple criteria

    Quote Originally Posted by jturner12 View Post
    Is there a way to make it B:B and C:C etc. so it covers new records too?
    You should avoid using entire columns as references with this formula.

    Just make the references larger (but not too large!) in anticipation of additional data. Then use this version which includes a test for empty cells.

    =SUM(IF(FREQUENCY(IF((B$4:B$100=B4)*(C$4:C$100=C4),IF(D$4:D$100<>"",MATCH(D$4:D$100,D$4:D$100,0))),ROW(D$4:D$100)-ROW(D$4)+1),1))

    Still array entered.

  9. #9
    Registered User
    Join Date
    10-27-2013
    Location
    London
    MS-Off Ver
    Excel 2007
    Posts
    13

    Re: Count number of entries based on multiple criteria

    Works perfectly. Thank you so much Tony!

  10. #10
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: Count number of entries based on multiple criteria

    You're welcome. Thanks for the feedback!


    If your question has been solved please mark the thread as being solved.

    In the menu bar above the very first post select Thread Tools, then select Mark this thread as solved.

+ 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] I Need to Count Number of Entries Based on Two Criteria
    By CLR in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 09-06-2005, 03:05 PM
  2. [SOLVED] I Need to Count Number of Entries Based on Two Criteria
    By Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 12:05 PM
  3. I Need to Count Number of Entries Based on Two Criteria
    By Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  4. I Need to Count Number of Entries Based on Two Criteria
    By CLR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 07:05 AM
  5. [SOLVED] I Need to Count Number of Entries Based on Two Criteria
    By CLR in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-06-2005, 04:05 AM
  6. [SOLVED] I Need to Count Number of Entries Based on Two Criteria
    By Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM
  7. [SOLVED] I Need to Count Number of Entries Based on Two Criteria
    By Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 02:05 AM
  8. [SOLVED] I Need to Count Number of Entries Based on Two Criteria
    By Jones in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2005, 10: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