+ Reply to Thread
Results 1 to 8 of 8

Thread: Counting unique values

  1. #1
    Forum Contributor
    Join Date
    06-21-2006
    MS-Off Ver
    2007
    Posts
    121

    Counting unique values

    I have two columns of data that I need to analyze by counting the number of unique values.

    A sample of the data would be in column A there are client names, and in column B there are tasks. I have a function that will give me the count even if a client is entered more than once. So, if the client has the same task done twice, I've been able to accomplish only counting it once. In this useless little example, it counts Bob - Rig as 1.

    The formula for that was =SUMPRODUCT((A20:A50<>"")/COUNTIF(A20:A50,A20:A50&""))

    Column A Column B
    Bob Rig
    Mark Call
    Bob Rig
    Bob Call
    Mark Rig

    My issue is, I'd like to count the number of unique items from column B. So, if I wanted to count the number of Rig, it would only be 2, as Bob Rig is in there twice.

    Thanks!
    Last edited by braydon16; 03-01-2011 at 01:06 PM.

  2. #2
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,712

    Re: Counting unique values

    Using your posted example...
    and
    D1: a Col_B value to count...eg Rig

    This formula returns the count of unique Col_A values where the Col_B value matches D1
    E1: =SUMPRODUCT((MATCH(A1:A10&B1:B10&"_",A1:A10&B1:B10&"_",0)=(
    ROW(A1:A10)-ROW(A1)+1))*(B1:B10=D1))

    Using your example, the formula returns: 2

    Is that something you can work with?
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  3. #3
    Forum Contributor
    Join Date
    06-21-2006
    MS-Off Ver
    2007
    Posts
    121

    Re: Counting unique values

    It's certainly something I can work with. Thanks!

  4. #4
    Forum Contributor
    Join Date
    06-21-2006
    MS-Off Ver
    2007
    Posts
    121

    Re: Counting unique values

    If I have a third column that contains amounts, Column C, can I just show the maximium from the values from a specific criteria from Column A?

  5. #5
    Cheeky Forum Moderator Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2003, 2007, 2010
    Posts
    3,712

    Re: Counting unique values

    Just so we're clear...can you post a small example and what you want returned?
    Regards,

    Ron
    Microsoft MVP - Excel
    (Oct 2006 - Sep 2012)

    Click here to see the Forum Rules

  6. #6
    Forum Contributor
    Join Date
    06-21-2006
    MS-Off Ver
    2007
    Posts
    121

    Re: Counting unique values

    Certainly. If I use the same example as above, but add an additional column with values...
    Column A Column B Column C
    Bob Rig 2
    Mark Call 3
    Bob Rig 2
    Bob Call 1
    Mark Rig 4

    If I specify that I want to know the max spent on Rigs? Can it return Bob and the sum, 4? In other words, I'm trying to find the maximum of the unique values.

  7. #7
    Forum Moderator daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2007
    Posts
    10,057

    Re: Counting unique values

    Assuming the same setup as Ron proposed then you could put this formula in F1 for the MAX spent on Rigs for a single person

    =MAX(MMULT((A1:A10=TRANSPOSE(A1:A10))+0,(B1:B10=D1)*C1:C10))

    and then in G1 for the person

    =INDEX(A1:A10,MATCH(F1,MMULT((A1:A10=TRANSPOSE(A1:A10))+0,(B1:B10=D1)*C1:C10),0))

    both formulas need to be confirmed with CTRL+SHIFT+ENTER

    for the latter if there are ties it just retrieves the first name
    Audere est facere

  8. #8
    Forum Contributor
    Join Date
    06-21-2006
    MS-Off Ver
    2007
    Posts
    121

    Re: Counting unique values

    Works like a charm...thank you!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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.2.0