+ Reply to Thread
Results 1 to 7 of 7

Formula to count unique columns

  1. #1
    Registered User
    Join Date
    05-09-2017
    Location
    Brasil
    MS-Off Ver
    2016
    Posts
    3

    Formula to count unique columns

    Hello,

    I need to do a counting of how many Calls have a certain Part Number. The hard part is: on the table, there are some Calls that have repeated PNs (part numbers) and I don't want to count those. (The table contain over 2.000 rows)

    For example:
    Call Part Number
    1050 0S1571
    1050 0T2080
    1030 0S1571
    1030 0T2080
    1050 0S1571

    I need the following result:

    0S1571: 2
    0T2080: 2
    Last edited by rmlucas; 05-10-2017 at 08:51 AM.

  2. #2
    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
    43,984

    Re: Formula to count unique columns

    One possible way:
    =SUM(INDEX(($B$2:$B$6=$F1)/COUNTIFS($A$2:$A$6,$A$2:$A$6,$B$2:$B$6,$B$2:$B$6),0))

    See sheet.
    Attached Files Attached Files
    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

  3. #3
    Registered User
    Join Date
    05-09-2017
    Location
    Brasil
    MS-Off Ver
    2016
    Posts
    3

    Re: Formula to count unique columns

    Thanks! It works!

  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
    43,984

    Re: Formula to count unique columns

    You're welcome & thanks for the rep.

  5. #5
    Registered User
    Join Date
    05-09-2017
    Location
    Brasil
    MS-Off Ver
    2016
    Posts
    3

    Re: Formula to count unique columns

    Actually, there's one problem... This formula takes too long to process, each cells takes up to 12 seconds to process, and I have to execute that formula on 4000 rows. There's another way to do this? I didn't understand how this part "COUNTIFS($A$2:$A$6,$A$2:$A$6,$B$2:$B$6,$B$2:$B$6)" works.

  6. #6
    Registered User
    Join Date
    01-19-2017
    Location
    Michigan
    MS-Off Ver
    2013
    Posts
    92

    Re: Formula to count unique columns

    Countifs counts the number of cells in a range that meet mutliple criteria. I'll give an example from a course I had since the book is in front of me.

    A B C D
    Daniels Jackson elementary XXX
    Wanda Hillsdale high school XXXX
    Lewis Jackson high school XXXXX
    Williams Jackson high school XX
    Shreev Acorn Intermediate XX


    =COUNTIFS(C2:C13, "high school", B2:B13, "Jackson")

    The formula goes like this =Countifs(criteria_range1, criteria, criteria_range2, criteria2, ...) all the way up to 127

    This basically counts all the "high school" criterion in C2:C13 and matches it to the criterion in B2:13 which is Jackson, thus the result of it would be 2.


    If I understand that formula correctly, it's counting A2-A6 with the matching criterion and doing the same for B2-B6 and outputting a number (within the sum function).
    Last edited by Xandler; 05-15-2017 at 09:41 AM.

  7. #7
    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
    43,984

    Re: Formula to count unique columns

    Try this instead. However, you may need VBA, as you are expecting Excel to do rather a lot!!!

    =SUM(--(FREQUENCY(IF(B$2:B$6=F1,MATCH($A$2:$A$6,$A$2:$A$6,0)),ROW($A$2:$A$6)-ROW($B$2)+1)>0))

    This is an array formula.
    Array Formulae are a little different from ordinary formulae in that they MUST be confirmed in the FIRST CELL ONLY by pressing CTRL+SHIFT+ENTER to activate the array, not just ENTER. After that, the array can be dragged down as normal, to cover the desired range.

    You will know the array is active when you see curly brackets { } - or "curly braces" for those of you in the USA, or "flower brackets" for those of you in India - appear around the outside of your formula. If you do not use CTRL+SHIFT+ENTER you will (almost always) get an error message or an incorrect answer. Press F2 on that cell and try again.

    Don't type the curly brackets yourself - it won't work...
    Attached Files Attached Files
    Last edited by Glenn Kennedy; 05-15-2017 at 09:54 AM.

+ 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. (Count Formula) Count if two seperate ranges create unique combination
    By Geekcrux in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 01-10-2016, 07:00 AM
  2. [SOLVED] Count Unique Items in a Column Based on Unique Items in Two Other Columns
    By HangMan in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 10-31-2015, 04:48 PM
  3. [SOLVED] Count unique from three columns
    By YasserKhalil in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-28-2015, 09:08 PM
  4. [SOLVED] count unique entries in 2 columns
    By VickiVA in forum Excel General
    Replies: 6
    Last Post: 08-05-2015, 09:26 AM
  5. [SOLVED] Sort and Count Unique List Across Multiple Columns - Student Count
    By BuntyMac in forum Excel Formulas & Functions
    Replies: 22
    Last Post: 08-17-2014, 07:00 AM
  6. [SOLVED] Count unique value for each row in a number of Columns
    By rickyilas in forum Excel General
    Replies: 6
    Last Post: 05-23-2012, 09:14 PM
  7. Count values where unique in both columns
    By krabople in forum Excel General
    Replies: 2
    Last Post: 06-24-2009, 06:08 AM

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