+ Reply to Thread
Results 1 to 6 of 6

Counting unique values in a separate column

  1. #1
    Registered User
    Join Date
    02-09-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    92

    Counting unique values in a separate column

    I have a table with the following columns:

    Column
    • Column A - Country
    • Column B - Office Type

    I need to create a formula that returns a list of unique values from Column A, if the value in Column B = 'Office'. So in other words, rather than just tell me how many countries appear in Column A (many of which will be the same), I want to number of distinct countries we have offices in.

    Any help much appreciated!

    Thanks

  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,812

    Re: Counting unique values in a separate column

    Your title and description are at odds - what do you want? A count or a list?
    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
    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,812

    Re: Counting unique values in a separate column

    For a count:

    =SUMPRODUCT((1/(COUNTIF($A$1:$A$1000,$A$1:$A$1000))*($B$1:$B$1000="Office")))

  4. #4
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,036

    Re: Counting unique values in a separate column

    Hi there.

    A picture is worth 1,000 words. An Excel sheet is worth 1,000 pictures.

    Please read the yellow banner about sample worksheets, at the top of the screen. Act on its guidelines and post a SMALL sample sheet.
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  5. #5
    Registered User
    Join Date
    02-09-2015
    Location
    London
    MS-Off Ver
    2013
    Posts
    92

    Re: Counting unique values in a separate column

    Thank you - and sorry if my title / post was confusing.

    I want a count of all of the distinct values in 'Country' column, if we were to filter the 'Office Type' column to 'Office'.

    So I guess it would be done in two stages: What is the count of values in Column A when Column B = 'Office', and then what is the number of unique values in Column A.

    I've tried your suggested formula but it bring up the wrong value (it should bring up 43, but it produces 68).

    Have included the worksheet if that makes it easier?
    Attached Files Attached Files

  6. #6
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Counting unique values in a separate column

    Please try

    =COUNT(1/FREQUENCY(IF(tbREMR7[Asset Type]="office",MATCH(tbREMR7[Country],tbREMR7[Country],)),ROW(tbREMR7)-ROW(tbREMR7[#Headers])))
    Ctrl+Shift+Enter

    or normal enter but slower with more data
    =SUMPRODUCT((tbREMR7[Asset Type]="office")/COUNTIFS(tbREMR7[Country],tbREMR7[Country],tbREMR7[Asset Type],tbREMR7[Asset Type]))
    Attached Files Attached Files

+ 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. Replies: 7
    Last Post: 10-23-2018, 10:18 AM
  2. [SOLVED] Count Unique Values and Sum a Separate Column
    By pbcsd in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-20-2014, 03:17 PM
  3. Counting unique values across more than one column
    By Lija in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 05-15-2013, 06:20 PM
  4. [SOLVED] counting unique values in col A against unique value in column B
    By greyscale in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-08-2013, 08:43 AM
  5. [SOLVED] Counting unique values from data on TWO separate excel tabs
    By rshukla in forum Excel General
    Replies: 2
    Last Post: 05-06-2013, 02:08 AM
  6. [SOLVED] Counting unique values from data on TWO separate excel tabs
    By rshukla in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-05-2013, 05:22 PM
  7. [SOLVED] Store Column A & B values in separate arrays for every unique value in Column A
    By tenscourts in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-30-2012, 09:53 AM

Tags for this Thread

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