+ Reply to Thread
Results 1 to 7 of 7

Count Unique Values that Meet a Criteria

  1. #1
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Count Unique Values that Meet a Criteria

    I need to count the number of staff that have been paid this year.
    I have searched the forum and can see solutions that use an array formula.
    However, the problem I have is that my file is in excess of 100,000 rows, and Excel tends to freeze when I enter the formula.
    I have attached a spreadsheet with a small number of records.
    The source data is in columns A-C.
    The pivot table in columns E-F shows that the answer I want is 5. I've included the pivot table just to show the answer that I need.
    Can anyone help by entering a formula in cell E13 that is based on columns B and C, bearing in mind that my actual file is very large?

    Many thanks
    David
    Attached Files Attached Files

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Count Unique Values that Meet a Criteria

    You can do this with a Pivot Table but add to data model first and you will get Value Field Setting = Distinct Count.
    See att.

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Count Unique Values that Meet a Criteria

    Not sure how you get 5 in E12 (if that was your expected answer?)

    I did this with a helper column (I used D)with this in D2, copied down. You could put it elsewhere, and/or you can hide it...
    =IF(COUNTIFS($A$2:A2,">"&EOMONTH(A2,-1),$A$2:A2,"<="&EOMONTH(A2,0),$B$2:B2,B2)>1,"",1)
    copied down.

    Then to get the count of EE's...
    F4=COUNTIFS(B:B,E4,D:D,1,C:C,"Yes")
    copied down
    E
    F
    4
    A1
    1
    5
    A2
    3
    6
    A3
    1
    7
    A4
    1
    8
    A5
    0
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Re: Count Unique Values that Meet a Criteria

    Thanks Sandy. I should have said that I am using Excel 2007 and unfortunately that option isn't available.
    Thanks for taking the time to reply. I look forward to my workplace updating our version of MS Office

  5. #5
    Registered User
    Join Date
    07-12-2005
    Location
    Canberra, Australia
    MS-Off Ver
    2007
    Posts
    43

    Re: Count Unique Values that Meet a Criteria

    Thanks Ford. This is quite a nifty solution. The 5 in cell E12 is arrived at because there are 7 employees in total (i.e. 7 unique employee ID codes) and only employees A6 and A7 were not paid. I was hoping that I could simply enter a formula in a single cell, much like an array formula, but one that doesn't freeze my computer. From Sandy's reply it seems like there are other options in later versions of Excel.
    Regards,
    David

  6. #6
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Count Unique Values that Meet a Criteria

    Put your Excel version into profile. Will be less mistakes

    EDIT:
    check here for Ex 2007
    Unique count in Excel Pivot Table - Add formula in source data
    or
    Here
    Last edited by sandy666; 03-09-2016 at 07:49 PM. Reason: link added

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,929

    Re: Count Unique Values that Meet a Criteria

    Quote Originally Posted by sandy666 View Post
    Put your Excel version into profile. Will be less mistakes

    EDIT:
    check here for Ex 2007
    Unique count in Excel Pivot Table - Add formula in source data
    or
    Here
    Also, please include your region, some regions use different settings, and we need to know that to format formulas for you

+ 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. How to count unique values in two ranges that meet conditions
    By akbermo in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-18-2015, 08:22 AM
  2. Replies: 7
    Last Post: 11-08-2014, 04:05 PM
  3. [SOLVED] Counting Unique Values Which Meet Criteria
    By Sophie.Durrant in forum Excel Formulas & Functions
    Replies: 9
    Last Post: 07-15-2013, 10:09 AM
  4. [SOLVED] Count Unique Values in Column A that meet criteria in Column B
    By ashakespeare in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 10-04-2012, 07:33 PM
  5. Replies: 25
    Last Post: 05-31-2012, 08:03 PM
  6. Replies: 5
    Last Post: 03-13-2012, 06:05 AM
  7. How to count unique entries that meet two criteria
    By Gooford in forum Excel General
    Replies: 2
    Last Post: 11-23-2010, 12:13 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