+ Reply to Thread
Results 1 to 14 of 14

I want to count the occurrences of UNIQUE values within a GROUP

Hybrid View

  1. #1
    Registered User
    Join Date
    05-06-2017
    Location
    Canada
    MS-Off Ver
    Office 365 subscription
    Posts
    44

    I want to count the occurrences of UNIQUE values within a GROUP

    I want to count the occurrences of UNIQUE values within a GROUP - I know how to find and count the unique values, but I don't know HOW to tell Excel what a GROUP consists of, i.e. where one ends and a new one starts.

    I have created a representative example for my problem, see attachment.
    Attached Files Attached Files
    Last edited by MinisoftEggshell; 01-28-2022 at 04:56 AM.

  2. #2
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Post a small Excel sheet (not a picture) showing realistic & representative sample data WITHOUT confidential information (10-20 rows, not thousands...) and some manually calculated results. For a new thread (1st post), scroll to Manage Attachments, otherwise scroll down to GO ADVANCED, click, and then scroll down to MANAGE ATTACHMENTS and click again. Now follow the instructions at the top of that screen.

  3. #3
    Registered User
    Join Date
    05-06-2017
    Location
    Canada
    MS-Off Ver
    Office 365 subscription
    Posts
    44

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    I uploaded the attachment, it should work now.
    Last edited by AliGW; 01-31-2022 at 04:19 AM. Reason: PLEASE don't quote unnecessarily!

  4. #4
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    i2=UNIQUE(FILTER(C2:C100,C2:C100<>""))

    j1=TRANSPOSE(UNIQUE(FILTER(B2:B100,B2:B100<>"")))


    J2=IF($I2<>"",COUNT(UNIQUE(FILTER($C$2:$C$100,($C$2:$C$100=$I2)*($B$2:$B$100=J$1)))),"")

    Copy across and down
    Attached Files Attached Files
    Last edited by CARACALLA; 01-28-2022 at 05:57 AM.

  5. #5
    Registered User
    Join Date
    05-06-2017
    Location
    Canada
    MS-Off Ver
    Office 365 subscription
    Posts
    44

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    In every cell it says 1, but the value 10 occours three times in the Applejuice group? And two times within the Oranges group. Why is every occourence 1?

  6. #6
    Forum Expert wk9128's Avatar
    Join Date
    08-15-2020
    Location
    China Shanghai
    MS-Off Ver
    365 V2502 and WPS V2024(12.1.0.18543)
    Posts
    3,842

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Misunderstood, delete it
    Last edited by wk9128; 01-28-2022 at 06:02 AM.

  7. #7
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,982

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    j2=IF($I2<>"",COUNTIFS($C$2:$C$100,$I2,$B$2:$B$100,J$1),"")

    copy across and down
    Attached Files Attached Files

  8. #8
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    This is not the best way, for sure...


    =TRANSPOSE(UNIQUE(B2:B23))

    and

    =LET(a,SORT(UNIQUE($C$2:$C$23)),CHOOSE({1,2,3,4},a,COUNTIFS(C2:C23,a,B2:B23,M1),COUNTIFS(C2:C23,a,B2:B23,N1),COUNTIFS(C2:C23,a,B2:B23,O1)))
    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

  9. #9
    Registered User
    Join Date
    05-06-2017
    Location
    Canada
    MS-Off Ver
    Office 365 subscription
    Posts
    44

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Thank you very much, that helped a great deal!

  10. #10
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Who were you talking to??

  11. #11
    Registered User
    Join Date
    05-06-2017
    Location
    Canada
    MS-Off Ver
    Office 365 subscription
    Posts
    44

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Quote Originally Posted by Glenn Kennedy View Post
    Who were you talking to??
    Generally I was talking to both of you because I do appreciate your help. Before you posted your solution I already altered CARACALLA's formula for my actual sheet. Which solution is more efficient, that's something I cannot decide because I have very limited knowledge in Excel. The sheet this formula is intended for has 3000 rows and 400 groups and 150 IDs

  12. #12
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2406
    Posts
    44,662

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Caracalla's will be better for the scale of your problem. I know that there will be a great way to do it, using the approach that I took... but it is not springing to mind!! If inspiration strikes, I'll repost on this thread.

    You're welcome.



    It would be very nice if you were to just click the Add Reputation button at the foot of any of the posts of members who helped you reach a solution.

    Finally, if that takes care of your original question, please select "Thread Tools" from the menu link (just above the first post in the thread) and mark this thread as SOLVED.

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

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    Please try

    =LET(z,B1:C23,g,INDEX(z,,1),id,INDEX(z,,2),uid,UNIQUE(id),ug,TRANSPOSE(UNIQUE(g)),f,COUNTIFS(g,ug,id,uid),IF(SEQUENCE(,COUNTA(ug),0),IF(SEQUENCE(ROWS(uid),,0),f,ug),SUBSTITUTE(uid,"ID","ID/Group")))

    or

    =LET(z,B1:C23,g,INDEX(z,,1),id,INDEX(z,,2),uid,TRANSPOSE(UNIQUE(id)),ug,UNIQUE(g),f,COUNTIFS(g,ug,id,uid),IF(SEQUENCE(COUNTA(ug),,0),IF(SEQUENCE(,COUNTA(uid),0),f,ug),SUBSTITUTE(uid,"ID","Group/ID")))
    Attached Files Attached Files

  14. #14
    Registered User
    Join Date
    05-06-2017
    Location
    Canada
    MS-Off Ver
    Office 365 subscription
    Posts
    44

    Re: I want to count the occurrences of UNIQUE values within a GROUP

    wow that's a complex formula but it works nicely! @Bo_Ry, in the example sheet I provided are the two columns Group and ID next to one another. In my real sheet these two columns are B and I - I was trying to figure out whether or not it's possible to use that formula but leaving the column structure intact?

    OK never mind I figured it out myself I expanded the range in z and edited the indexes in g and id accordingly.

    It really fascinates me, this formula
    Last edited by MinisoftEggshell; 01-31-2022 at 10:18 AM. Reason: figured it out myself

+ 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 each unique value and it's occurrences
    By zudecke in forum Excel General
    Replies: 13
    Last Post: 02-01-2018, 05:26 AM
  2. Replies: 19
    Last Post: 05-29-2014, 04:49 PM
  3. Count unique occurrences, segmented by two columns
    By brendanyoung in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-22-2013, 03:28 PM
  4. Replies: 8
    Last Post: 05-15-2013, 04:50 PM
  5. Count unique occurrences with sumproduct
    By dana26 in forum Excel Formulas & Functions
    Replies: 18
    Last Post: 02-03-2013, 11:55 PM
  6. Count unique occurrences with criteria
    By Alaina Readman in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 11-01-2007, 04:41 PM
  7. [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