Consulting

Results 1 to 5 of 5

Thread: Count unique values based on another column

  1. #1
    VBAX Regular
    Joined
    Sep 2011
    Posts
    16
    Location

    Count unique values based on another column

    Hi everyone!

    I have a Excel sheet with two (applicable) sheets:
    The first sheet has a list of Job Codes in column A.

    The second sheet has multiple columns, (starting with A): PO Number, PO Line, Item...then the last column is the Job Code Reference column.

    The PO Number can repeat if there are multiple lines, and a Job Code can be referenced on more than one PO.

    I am going to use another column on the first sheet for my formula which is where my question is:

    I would like to use the Job Code value on sheet one to look up all instances of PO Numbers on the second sheet based on the Job Code Reference Column. If there is more than one referenced PO, return the string "Multiple", otherwise just return the one PO Number, even if there are multiple PO Lines.

    How would I go about doing this?

    Edit: Added example attachment
    Attached Files Attached Files

  2. #2
    VBAX Regular
    Joined
    Mar 2013
    Posts
    38
    Location
    mmmm you only need one formula (my excel is in spanish so you should review ortography before using it)

    =if(countif(sheet2!A:A,a1)>1,"Multiple",sumif(sheet2!c:c,a1,sheet2!a:a))
    "Amat Victoria Curam"

  3. #3
    VBAX Regular
    Joined
    Sep 2011
    Posts
    16
    Location
    Quote Originally Posted by enrand22
    mmmm you only need one formula (my excel is in spanish so you should review ortography before using it)

    =if(countif(sheet2!A:A,a1)>1,"Multiple",sumif(sheet2!c:c,a1,sheet2!a:a))

    Take a look at the attached file. Maybe I am doing the formula wrong, but instead of saying multiple, it is adding up every single PO Number. Even for the PO it finds for row 4 on sheet 1 it is adding up the duplicate occurrences.
    Attached Files Attached Files

  4. #4
    VBAX Regular
    Joined
    Mar 2013
    Posts
    38
    Location
    that was my bad... but just change for this one

    at first i was counting the column A:A instead of the column C:C

    =if(countif(sheet2!c:c,a1)>1,"Multiple",sumif(sheet2!c:c,a1,sheet2!a:a)

    here it is the attached correction.
    Attached Files Attached Files
    "Amat Victoria Curam"

  5. #5
    VBAX Regular
    Joined
    Mar 2013
    Posts
    38
    Location
    that was my bad... but just change for this one

    at first i was counting the column A:A instead of the column C:C

    =if(countif(sheet2!c:c,a1)>1,"Multiple",sumif(sheet2!c:c,a1,sheet2!a:a)

    here it is the attached correction.
    "Amat Victoria Curam"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •