+ Reply to Thread
Results 1 to 7 of 7

count unique values in one column after specifying > 0 in another column

  1. #1
    Registered User
    Join Date
    12-26-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    11

    count unique values in one column after specifying > 0 in another column

    Hello,
    I would like to count unique values in one column after specifying for numbers > 0 in another column. I desire a formula, but not a control+shift+enter formula (which are easy to invalidate by accidentally pressing enter or tab).

    My dataset is where Jam, Type, and Zone1 are in A1, B1, and C1, respectively, and the data starts in A2, B2, and C2.

    I would like to find unique Jam values where Zone1 > 0. The result should be 14.

    I've tried the following formula, but it's finding the unique Jam values for each of the unique values where Zone1 > 0 (10, 25,50, and 75), then adding them together.

    For instance, the formula below is finding these unique jams, then adding them together for a result of 17, which is not what I want.

    where Zone1 = 10, there is 1 unique Jam;
    where Zone1 = 25, there are 9 unique Jams;
    where Zone1 = 50, there are 5 unique Jams;
    where Zone1 = 75, there are 2 unique Jams;

    =SUMPRODUCT((C2:C29>0)/COUNTIFS(A2:A29,A2:A29,C2:C29,C2:C29))


    Jam Type Zone1
    1 xs 25
    1 s 75
    2 xs 25
    2 s 25
    3 xs 0
    3 s 0
    4 xs 0
    5 xs 50
    6 xs 25
    7 xs 10
    7 s 0
    8 xs 50
    9 xs 25
    9 s 0
    10 xs 25
    10 s 25
    11 xs 0
    11 s 0
    12 xs 50
    12 s 25
    13 xs 25
    13 s 0
    14 xs 25
    15 xs 0
    16 xs 50
    16 s 75
    17 xs 25
    18 xs 50

    Thank you for your assistance.

  2. #2
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: count unique values in one column after specifying > 0 in another column

    this formula does not need to be three-finger confirmed:

    Please Login or Register  to view this content.
    - i.s.z -
    CSE, aka Array aka { }, formulae are confirmed with CONTROL+SHIFT+ENTER.
    Replace commas ( , ) with semicolons ( ; ) in formulae, if your locale setting demands.
    All good ideas are courtesy resources from this forum as well as others around the web.
    - e.o.m -

  3. #3
    Registered User
    Join Date
    12-26-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: count unique values in one column after specifying > 0 in another column

    Thank you so much. I posted the question, and it was solved within an hour! I will mark this question as solved.

  4. #4
    Registered User
    Join Date
    12-26-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: count unique values in one column after specifying > 0 in another column

    Oops, the formula only works in the datasets where colmun A (Jam) is in sequential order, and there are no blanks in column C (Zone1). I seem to have some datasets like the first example (sequential order, and no blanks), and other datasets where it's not in sequential order and there are some blanks. I could insert a not applicable number into the blanks, like 999, if a formula cannot be generated to ignore blanks in column C (Zone1).

    Here is another list, where Jam is not in sequential order, and Zone1 has some blanks. Thank you in advance for your help.

    Jam Type Zone1
    (blank) (blank) (blank)
    (blank) (blank) (blank)
    2 none (blank)
    3 none (blank)
    4 none (blank)
    7 none (blank)
    8 none (blank)
    16 none (blank)
    1 xs 10
    1 s 3
    2 xs 5
    2 s 2
    3 xs 3
    3 s 3
    4 xs 10
    5 xs 6
    6 xs 5
    7 xs 19
    7 s 2
    8 xs 4
    9 xs 16
    9 s 1
    10 xs 8
    10 s 1
    11 xs 3
    11 s 3
    12 xs 7
    12 s 1
    13 xs 7
    13 s 1
    14 xs 5
    15 xs 8
    16 xs 26
    16 s 2
    17 xs 9
    18 xs 11
    (blank) (blank) (blank)
    (blank) (blank) (blank)

  5. #5
    Forum Expert icestationzbra's Avatar
    Join Date
    01-07-2004
    MS-Off Ver
    2007, 2010
    Posts
    1,421

    Re: count unique values in one column after specifying > 0 in another column

    see attached...

    also, provide sample workbooks, instead of pasting a whole lot of data in threads; it is a hassle to have to recreate your dataset.

    EDIT:

    file updated with a single helper column.

    EDIT (01JAN13):

    file updated with better helper column formula:
    Last edited by icestationzbra; 01-01-2013 at 04:52 PM. Reason: file updated with a single helper column

  6. #6
    Registered User
    Join Date
    12-26-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: count unique values in one column after specifying > 0 in another column

    I've tested the stand-alone formula with about a dozen datasets, and it works. Somehow when you uploaded the file, the zone1 got out of order (sorry for not uploading a file in the first place). I'm uploading the file again with the correct zone1. The stand alone formula works, however the formula with the helper does not. I prefer the stand-alone formula anyway, which seems to work regardless if there are blanks or whether the dataset is in sequential order. Very clever!

    I've managed tweak the formula again and again using different parameters on datasets where I first need to exclude zeros (or some other number) in one column, then count unique values in a different column. Thanks again.

  7. #7
    Registered User
    Join Date
    12-26-2012
    Location
    US
    MS-Off Ver
    Excel 2007
    Posts
    11

    Re: count unique values in one column after specifying > 0 in another column

    Thanks for the update on the helpler column. Now both the helper formula and stand alone formulas work. Thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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