Search code examples
excelgroupingcountif

How to count similar groups of items in a list using Excel?


I thought I was getting pretty good with Excel sumifs/maxifs/minifs/countifs but I am stuck on this one. I am trying to count the number of grouped elements in a list, using a concise formula in a single column (manually copied down the array range) preferably using one of my favorites mentioned above and without using Excel's annoying array function where you have to press Ctrl/Shift/Enter, and without using VBA. I illustrate and explain the desired outputs of block group counts below in yellow. Any ideas for a formula that does this?

The << Formula columns are only illustrating countifs() using a single condition and multiple conditions, respectively.

enter image description here


Solution

  • This uses a spill range array (same as ctl shift enter) without pressing it. Hopefully you have that functionality.

    =SUMPRODUCT(--ISNUMBER(FIND(A2,UNIQUE(FILTER(A$2:A2&B$2:B2,A$2:A2<>"")))))
    

    See example on Google Sheets but will work on excel.