+ Reply to Thread
Results 1 to 5 of 5

Match data in 1 column and count unique data in another column based on matches

  1. #1
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    954

    Match data in 1 column and count unique data in another column based on matches

    Hello,

    I was curious if anyone would have an alternate formula to use to match data in one column and count unique data in another column that wouldn't require an Array? I found the array formula below and it works, but my worksheet has 60,000 rows and this formula takes forever to calculate, which makes it impossible to use. I was hoping for an alternative formula that may not require as much computer resources and could provide the results in a timely fashion. Appreciate any suggestions/alternative formulas!

    Array formula:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by lilsnoop; 11-28-2020 at 12:31 PM.

  2. #2
    Forum Expert XLent's Avatar
    Join Date
    10-13-2010
    Location
    Northumberland, UK
    MS-Off Ver
    various
    Posts
    2,704

    Re: Match data in 1 column and count unique data in another column based on matches

    given version (XL2013) and the sample data (where A is seemingly sorted Asc) then you might try switching to:

    C3:
    =IF($A3=$A2,$C2,SUMPRODUCT(1/COUNTIF($B3:INDEX($B:$B,MATCH($A3,$A:$A)),$B3:INDEX($B:$B,MATCH($A3,$A:$A))&"")))
    copied down

    the above (c/o Col A being sorted)

    a) only calculates the unique number once per item A (the other A items use the previously calculated result)
    b) switches from multi criteria COUNTIFS to single criteria -- this has a big impact on performance (for COUNTIFS - specifically) aside the most recent XL versions (which fix the 'bug')
    c) limits the range of each COUNTIF calc such that it very small {c/o binary search based MATCH}

    so, with the above changes, you should find the performance improves a fair bit when applied to a large dataset

  3. #3
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Match data in 1 column and count unique data in another column based on matches

    Please try

    =COUNT(1/FREQUENCY(IF($A$3:$A$40000=A3,MATCH($B$3:$B$40000,$B$3:$B$40000,)),ROW(A$3:A$40000)-ROW($A$3)))

    Ctrl+Shift+Enter
    Attached Files Attached Files

  4. #4
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    Taiwan
    MS-Off Ver
    365 V2403 and WPS V2022
    Posts
    3,400

    Re: Match data in 1 column and count unique data in another column based on matches

    D3 , Array formula , Copy and drag down

    HTML Code: 

  5. #5
    Valued Forum Contributor
    Join Date
    03-17-2007
    Location
    Michigan
    MS-Off Ver
    Excel 2016
    Posts
    954

    Re: Match data in 1 column and count unique data in another column based on matches

    Thanks XLent, Bo_Ry & wk9128 Really appreciate your formula suggestions! Thanks so much!

+ 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] Count Unique Values with Partial Match one column exact match another column
    By carsto in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 07-30-2019, 09:56 AM
  2. [SOLVED] Pulling data from a column based on if it matches data if another column
    By Aredeekay in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-19-2019, 08:32 AM
  3. [SOLVED] Count unique data in Column, but exclude if certain data is in another Column
    By dgroff in forum Excel Formulas & Functions
    Replies: 11
    Last Post: 12-12-2014, 01:41 PM
  4. Count Unique in one colum based on matches in other Column
    By ExcellentM in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 12-04-2012, 03:22 PM
  5. Replies: 5
    Last Post: 06-01-2011, 01:19 PM
  6. Replies: 2
    Last Post: 07-29-2010, 09:57 AM
  7. Replies: 16
    Last Post: 02-09-2009, 07:29 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