+ Reply to Thread
Results 1 to 20 of 20

How do you list unique values in Excel and count occurrences of each?

  1. #1
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Question How do you list unique values in Excel and count occurrences of each?

    Hi,

    I require some help from the team here. I realise this is beyond me and wonder if it is possible to list uniqure values in excel and place a count occurrences of each. I have a hugh list of over 400 alpha code i.e ABCD, ABCD, ABCE, BDCE, BDCF ZXYE etc etc. What I'd like to do is pick out all the unique values so I can see what alpha codes are on the list. But then I would also like to count the occurrences of each value/name so I know how many times they appeared on the list.

    Col A
    ABCD
    ABCD
    ABCE
    BDCE
    BDCF
    ZXYE
    ZXYE
    YEZY
    CDEF

    Col B is where i would like to list all the unquie vaules with a count e.g.
    ABCD 2
    ABCE 1
    BDCE 1
    BDCF 1
    ZXYE 2
    YEZY 1
    CDEF 1

    Any help here would be appreciated.

    Regards,
    Ravi

  2. #2
    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
    53,044

    Re: How do you list unique values in Excel and count occurrences of each?

    Put this in B2 and copy down...
    =IFERROR(INDEX($A$2:$A$10,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$10),0,0),0)),"")

    Then in C2, copied down...
    =IF(B2="","",COUNTIF($A$2:$A$10,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

  3. #3
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How do you list unique values in Excel and count occurrences of each?

    Here is another non-array solution for the unique listing. Data starts in A1. This formula will ignore blank cells in the list if there are any. Enter in B2 and copy down.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enter this in C2 and copy down: (same formula as FDibbins for counting only the cell references differ because of different start cell of data.)

    Formula: copy to clipboard
    Please Login or Register  to view this content.
    <---------If you like someone's answer, click the star to the left of one of their posts to give them a reputation point for that answer.
    Ron W

  4. #4
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How do you list unique values in Excel and count occurrences of each?

    Here's another option.

    Use advanced filter.

    Let's assume your data is in the range A2:A10 and cell A1 is the column header.

    Select the range including the column header A1:A10.

    Goto the Data tab>Sort & Filter group>Advanced
    Select: Copy to another location
    Copy to: B1
    Select: Unique records only
    OK

    Then, to get the counts, enter this formula in B2 and copy down as needed:

    =COUNTIF(A:A,B2)
    Biff
    Microsoft MVP Excel
    Keep It Simple Stupid

    Let's Go Pens. We Want The Cup.

  5. #5
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Thanks team really appreciate the answers. I will try it shortly once I get sometime. I will come back with the outcome.

  6. #6
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Quick correction to my orginal request sorry this was my mistake. Col A Data is in a seperate TAB called Data.

    My calculation sheet is called PROBLEM MGT where i want to resolve the unique in excel and place a count occurrences of each.

    So the answers provided FDibbins and newdoverman would the formula change?

  7. #7
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Hi Tony,

    I will try the advance filter options as well. Just wanted to ask you would the advance filter method be ok as the data grows everyday ?

  8. #8
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How do you list unique values in Excel and count occurrences of each?

    The filter method described in reply #4 would have to be redone whenever you add new data to the range.

    However, you can automate this completely by using an event macro.

    See this thread:

    http://www.excelforum.com/excel-prog...pty-cells.html

  9. #9
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Thanks Tony. I have managed to get it work with PivotTable. I am still going to try your method.

  10. #10
    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
    53,044

    Re: How do you list unique values in Excel and count occurrences of each?

    Post 2 and 3 will update as you add new data

  11. #11
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How do you list unique values in Excel and count occurrences of each?

    Quote Originally Posted by rpc06 View Post
    Thanks Tony. I have managed to get it work with PivotTable. I am still going to try your method.
    If I'm not mistaking, you have to refresh a pivot table to get it to update.

    Depending on how much data there is to evaluate and how many unique items there are, formulas to do this might be a bit slow to calculate.

    You should probably try the formula suggestions first and see if the performance is acceptable.

  12. #12
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Hi Tony,

    Yes I have noticed the formulas is take long time to calculate as my spreadsheet has 2000 rows of data. Hence I am using a pivot table now. Yes I will have to refresh as new data comes in and also i have to increase the range so the pivot table picks up new data.

  13. #13
    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
    53,044

    Re: How do you list unique values in Excel and count occurrences of each?

    Quote Originally Posted by rpc06 View Post
    Hi Tony,

    Yes I have noticed the formulas is take long time to calculate as my spreadsheet has 2000 rows of data.
    2000 rows of data should not slow your file down (depending on what else you have going on, of course)


    =IFERROR(INDEX('PROBLEM MGT'!$A$2:$A$10,MATCH(0,INDEX(COUNTIF($B$1:B1,'PROBLEM MGT'!$A$2:$A$10),0,0),0)),"")

    Then in C2, copied down...
    =IF(B2="","",COUNTIF($A$2:$A$10,B2))

    My calculation sheet is called PROBLEM MGT where i want to resolve the unique in excel and place a count occurrences of each.

  14. #14
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How do you list unique values in Excel and count occurrences of each?

    If your base data that the Pivot Table is created from is in a TABLE, as the table grows, all you have to do is to refresh the Pivot Table without changing the Data Source to match your expanded data. When you refresh the Pivot Table, make sure that the active cell in the data table worksheet is a cell in the data table otherwise any grouping could get messed up in the Pivot Table......learned from experience on that one.

  15. #15
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How do you list unique values in Excel and count occurrences of each?

    What else is going on in the worksheet? 2000 rows is really nothing at all.

  16. #16
    Forum Expert Tony Valko's Avatar
    Join Date
    12-31-2011
    Location
    Pittsburgh
    MS-Off Ver
    2002, 2007:2013
    Posts
    18,890

    Re: How do you list unique values in Excel and count occurrences of each?

    Quote Originally Posted by FDibbins View Post
    2000 rows of data should not slow your file down
    Quote Originally Posted by newdoverman View Post
    What else is going on in the worksheet? 2000 rows is really nothing at all.
    I notice that neither of you guys are using Excel 2013?

    Excel 2013 is slower than all previous versions.

    Using Excel 2013 (as is the OP?) on my machine (quad core Intel I3 w/8gb ram)...

    Worst case scenario:

    A2:A2000 = every cell contains a unique entry

    So, that means I needed 1999 of these formulas:

    =IFERROR(INDEX($A$2:$A$2000,MATCH(0,INDEX(COUNTIF($B$1:B1,$A$2:$A$2000),0,0),0)),"")

    It took my machine almost 5 minutes to return all 1999 unique entries.

    Your mileage may vary!

  17. #17
    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
    53,044

    Re: How do you list unique values in Excel and count occurrences of each?

    Thanks for the input, Tony, always appreciated Nope, dont have 2013 yet, and may not get it anyway

  18. #18
    Forum Expert newdoverman's Avatar
    Join Date
    02-07-2013
    Location
    Port Dover, Ontario, Canada
    MS-Off Ver
    2010
    Posts
    10,330

    Re: How do you list unique values in Excel and count occurrences of each?

    Thank you Tony. My machine is considerably different. i7 3770 (3.4 ghz) 16 GB ram, 4 actual +4 virtual cores. My laptop would be closer though AMD Quad core 6 GB ram.

    I set up the same situation with 2000 unique values and it took just over 6 minutes on the laptop.

  19. #19
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Hi all,

    ok will try creating a brand new spreadsheet and he how long it takes to calculate the vaules. Yes 2000 rows is nothing for a database. I will try this and get back to you all.

    Cheers.

  20. #20
    Registered User
    Join Date
    05-02-2014
    Location
    New Zealand
    MS-Off Ver
    2013
    Posts
    39

    Re: How do you list unique values in Excel and count occurrences of each?

    Hi, I am using 2013 hence that could be problem.

+ 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. [SOLVED] In a single cell, count any occurrences from a list of values
    By daedelous00 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-05-2013, 03:30 PM
  2. Replies: 8
    Last Post: 05-15-2013, 04:50 PM
  3. Count unique occurrences with sumproduct
    By dana26 in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 02-03-2013, 11:55 PM
  4. Count unique occurrences with criteria
    By Alaina Readman in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-01-2007, 04:41 PM
  5. [SOLVED] Count unique occurrences of name
    By jhicsupt in forum Excel General
    Replies: 4
    Last Post: 10-05-2005, 01:05 PM

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