+ Reply to Thread
Results 1 to 10 of 10

Unique Records in a Column with a twist

  1. #1
    Registered User
    Join Date
    11-16-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    19

    Talking Unique Records in a Column with a twist

    Hi All,

    I would like to place a formula in cells A2 down that does a running count of unique combinations of columns B and C.
    For example, the first record is a white dog, so at that point there is 1 category of dog, next is a brown dog, so there there is now 2 categories etc.

    I initially tried to adapt an array formula 1/COUNTIF($B$2:$B8,$B$2:$B8) but this wont quite do the trick.

    Please see file attached.
    Any ideas from anyone would be most appreciated.

    Thanks

    Ciaran Mc
    Attached Files Attached Files

  2. #2
    Forum Expert Jakobshavn's Avatar
    Join Date
    08-17-2012
    Location
    Lakehurst, NJ, USA
    MS-Off Ver
    Excel 2007
    Posts
    1,970

    Re: Unique Records in a Column with a twist

    In A2 enter:

    =COUNTIF($B$2:B2,B2)

    and copy down
    Gary's Student

  3. #3
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Unique Records in a Column with a twist

    THis will give you a count of unique B&C combinations, but based on your sample, that isnt what you want...
    =SUMPRODUCT(($B$2:$B$9=B2)*($C$2:$C$9=C2))

    this will give tyou a running count of unique items in B, which is exactly what your sample shows, but it completely ignores column C...
    =COUNTIF($B$2:B2,B2)
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  4. #4
    Registered User
    Join Date
    11-16-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Unique Records in a Column with a twist

    Hi Jakobshavn,

    I should have made my example a little clearer but this is not what Im looking for.
    Column A should show a running count of animal and colour. In this attachment, you can see that the first 2 records are white dogs. So cell A3 should be 1 as there is only 1 unique combinations of dog and colour so far ! Cell A8 is 2 with the introduction of another colour, if you get me

    Hope you can help

    Thanks

    Ciaran
    Attached Files Attached Files

  5. #5
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Unique Records in a Column with a twist

    I dont understand your logic...

    Please Login or Register  to view this content.
    you have 2 for cat-orange, but there is only 1 cat-orange
    yet you have dog-white twice but only count it once??

    Please explain exactly how you arrive at the answers you have, because it is not clear to me what you want

  6. #6
    Registered User
    Join Date
    11-16-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Unique Records in a Column with a twist

    Hi Dibbins, sorry this is a tricky one to explain !
    You are correct, there is only 1 orange cat, however oranage is the second cat colour used thus far. The last row is 3 because at that particular row there are 3 colours used for cat with the addition of pink also. So col A is counting the number of animal colurs used thus far !
    Hope this makes sense

    Thanks

    Ciaran

  7. #7
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,933

    Re: Unique Records in a Column with a twist

    If you can sort the data, you could use this, copied down...
    =IF(H2=H1,IF(I2=I1,K1,K1+1),1)

    Or perhaps try using a Pivot table, with...
    column lable = color
    row label = animal
    values = count of animals

  8. #8
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Unique Records in a Column with a twist

    hi Ciaran. try this array in A2:
    =SUM(IF(FREQUENCY(IF(B$2:B2=B2,MATCH(C$2:C2,C$2:C2,0)),ROW(B$2:B2)-ROW($B$2)+1)>0,1))

    you have to paste the formula inside the formula bar & press CTRL + SHIFT + ENTER

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  9. #9
    Forum Contributor
    Join Date
    12-23-2003
    Posts
    179

    Re: Unique Records in a Column with a twist

    Quote Originally Posted by ciaran01 View Post
    Hi Jakobshavn,

    I should have made my example a little clearer but this is not what Im looking for.
    Column A should show a running count of animal and colour. In this attachment, you can see that the first 2 records are white dogs. So cell A3 should be 1 as there is only 1 unique combinations of dog and colour so far ! Cell A8 is 2 with the introduction of another colour, if you get me

    Hope you can help

    Thanks

    Ciaran
    A2, control+shift+enter, not just enter, and copy down:
    Please Login or Register  to view this content.

  10. #10
    Registered User
    Join Date
    11-16-2012
    Location
    Edinburgh
    MS-Off Ver
    Excel 2003
    Posts
    19

    Re: Unique Records in a Column with a twist

    Great solution thanks a lot guys

+ 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