Countif as a dynamic array

Lz._ 38,106 Reputation points Volunteer Moderator
2022-06-09T12:00:15+00:00

Hi

(relates to Numbering an ID with some specific criteria)

Sample

Range A2:A11 aka SmallRange consists of non-unique IDs desordered

Goal

With formula only, generate a countif array. Expected result in green columns

Options so far

B2: =COUNTIF(OFFSET(A2,,,SEQUENCE(ROWS(SmallRange))),SmallRange) 

C2: =BYROW(LargeRange,LAMBDA(Id,COUNTIF(A2:Id,Id))) 

D2: =MAP(LargeRange,LAMBDA(Id,COUNTIF(A2:Id,Id)))

Unfortunately none seem to scale. In this file LargeRange consists of 100k rows and 100 unique IDs for checking and to dev. other options...

My current LAMBDA based solution that performs (I think) "decently" considering that range is avail. here

Thanks

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Anonymous
    2022-06-10T00:38:56+00:00

    Hi. Just 2 cents. My opinion is that CountIf Is not the best function to use for a few reasons.

    First, you are counting a large range multiple times.

    Second, it doesn't work well within functions (not ref a worksheet).

    There are other functions that can do your large range almost immediately.

    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Lz._ 38,106 Reputation points Volunteer Moderator
    2022-06-10T06:21:59+00:00

    Hi Rand

    Very much appreciate your 2 cents :) Would you mind sharing your Tally.ByOccur function or a link to your workbook?

    Thanks

    Hi Yuhao Li - MSFT

    Not sure your reply has something to do with this issue. If this is a mistake would you mind deleting it please?

    0 comments No comments
  4. Anonymous
    2022-06-17T00:41:05+00:00

    Already deleted

    0 comments No comments