+ Reply to Thread
Results 1 to 13 of 13

Count unique values with conditions

  1. #1
    Registered User
    Join Date
    11-15-2013
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    23

    Count unique values with conditions

    Hi,
    I need some help, I've spent an hour browsing a solution and I keep failing at putting examples together!

    Please can someone provide a formula to solve this:
    • I need to calculate unique values in Column A
    • I need two criteria, if these two match then it will count unique values in Column A
      Criteria 1: Check Column F matches criteria on Cell A2
      Criteria 2: Check Column G does not contain criteria on Cell A3


    Thanks in advance

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Count unique values with conditions

    There are instructions at the top of the page explaining how to attach your sample workbook.

    A good sample workbook has just 10-20 rows of representative data that has been desensitised. It also has expected results mocked up, relevant cells highlighted and a few explanatory notes.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    11-15-2013
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    23

    Re: Count unique values with conditions

    Here it is. Thank you
    Attached Files Attached Files

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Count unique values with conditions

    There is no manually calculated result - what result are you expecting from your sample data? A value, not a description, please.

  5. #5
    Registered User
    Join Date
    11-15-2013
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    23

    Re: Count unique values with conditions

    I want the number of unique names (sheet 2, column A) based on the criteria I set in sheet 1.

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Count unique values with conditions

    And that number is? Value, please.

    Are you still using Excel 2013?

  7. #7
    Registered User
    Join Date
    11-15-2013
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    23

    Re: Count unique values with conditions

    they will be names. so I just want to count it, just once, even though there may be duplicate names in the column. is that what you mean?

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Count unique values with conditions

    No, I wanted you to tell me what you were expecting the actual result to be for your very limited sample data. I assume 1, but you have failed to confirm this. Repeating a description when I have said I want a value and not a description doesn't get us very far!

    Try this:

    =SUMPRODUCT((1/(COUNTIF($A$2:$A$8,$A$2:$A$8))*($B$2:$B$8=Sheet1!$A$2)*($C$2:$C$8<>Sheet1!$A$3)))

    Are you still using Excel 2013?

    they will be names
    A COUNT cannot be a name - it has to be a number!!!
    Last edited by AliGW; 01-11-2022 at 06:31 AM.

  9. #9
    Registered User
    Join Date
    11-15-2013
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    23

    Re: Count unique values with conditions

    Oh, I'm so sorry! Totally went over my head Yes - the value I would expect is '1'

    That works perfectly, thank you so much!

    Lastly, do you have a solution if I wanted to extend data beyond the current data set (currently A2-A8, but if I set it at A2-A100 [for example]) as I'll be continuously adding data and currently it returns a #DIV/0 error if I set it to anything beyond A8. I suppose it's worth checking to omit empty cells?

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Count unique values with conditions

    Yes, I do - use a structurded table, and then you won't need to worry about the range needing to grow:

    =SUMPRODUCT((1/(COUNTIF(Table1[Name],Table1[Name]))*(Table1[Column]=Sheet1!$A$2)*(Table1[Column2]<>Sheet1!$A$3)))

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, if you have not already done so, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.
    Attached Files Attached Files

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Count unique values with conditions

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  12. #12
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Australia
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,413

    Re: Count unique values with conditions

    Worksheet name : Sheet1
    Cell C2 array formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    AliGw's Cell D2 formula

    Formula: copy to clipboard
    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    11-15-2013
    Location
    England
    MS-Off Ver
    Excel 2013
    Posts
    23

    Re: Count unique values with conditions

    Thank you both, very helpful and saved me time

+ 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. Count unique values based on two conditions
    By thomasuponor in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-25-2020, 09:13 AM
  2. [SOLVED] Count Unique values with conditions
    By Klaudiii in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-30-2019, 09:11 AM
  3. [SOLVED] Count unique values from a column with conditions
    By Fullspeeduws in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-30-2018, 08:19 AM
  4. [SOLVED] Count amount of unique values with multiple conditions
    By Melon6 in forum Excel General
    Replies: 17
    Last Post: 05-19-2015, 11:59 AM
  5. [SOLVED] Count only unique values with two conditions
    By Melon6 in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 05-01-2015, 05:24 AM
  6. Count unique values with multiple conditions
    By liybpg in forum Excel General
    Replies: 6
    Last Post: 03-18-2015, 05:43 AM
  7. [SOLVED] count the number of unique values given certain conditions
    By eh308701 in forum Excel General
    Replies: 8
    Last Post: 05-31-2012, 11:48 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