Unique Rank value for a subgroup within a group

落花浮王杯 提交于 2019-11-27 09:10:01

The good news is that you can throw away the SUMPRODUCT function and replace it with a pair of COUNTIFS functions. The COUNTIFS can use full column references without detriment and is vastly more efficient than the SUMPRODUCT even with the SUMPRODUCT cell ranges limited to the extents of the data.

In N2 as a standard function,

=COUNTIFS(B:B, B2,M:M, "<"&M2)+COUNTIFS(B$2:B2, B2, M$2:M2, M2)

Fill down as necessary.

      

  Filtered Results

     

 

 

Solution basing on OP

Studying your post demanding to post any alternatives, I got interested in a solution based on your original approach via the SUMPRODUCT function. IMO this could show the right way for the sake of the art:

Applied method

Get

  • a) all current ids with a group value lower or equal to the current value

    MINUS

  • b) the number of current ids with the identical group value starting count from the current row

    PLUS

  • c) the increment of 1

Formula example, e.g. in cell N5:

=SUMPRODUCT(($B$2:$B$38705=$B5)*($M$2:$M$38705<=$M5))-COUNTIFS($B5:$B$38705,$B5,$M5:$M$38705,$M5)+1

P.S.

Of course, I agree with you preferring the above posted solution, too :+)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!