组内子组的唯一排名值

发布于 2025-01-18 07:49:46 字数 563 浏览 4 评论 0原文

我正在尝试获得唯一的等级值(例如{1,2,3,4}从我的数据中的一个子组中。 ,我正在尝试将计端添加到终点,以调整副本的

                subgroup
col B   col M    rank
LMN       01      1
XYZ       02        
XYZ       02    
ABC       03    
ABC       01    
XYZ       01    
LMN       02      3
ABC       01    
LMN       03      4
LMN       03      4  'should be 5
ABC       02    
XYZ       02    
LMN       01      1  'should be 2   

=SUMPRODUCT(($B$2:$B$38705=B2)*(M2>$M$2:$M$38705))+countifs(B2:B38705=B2,M2:M38705=M2)

排名

I am trying to get a unique rank value (e.g. {1, 2, 3, 4} from a subgroup in my data. SUMPRODUCT will produce ties{1, 1, 3, 4}, I am trying to add the COUNTIFS to the end to adjust the duplicate rank away.

                subgroup
col B   col M    rank
LMN       01      1
XYZ       02        
XYZ       02    
ABC       03    
ABC       01    
XYZ       01    
LMN       02      3
ABC       01    
LMN       03      4
LMN       03      4  'should be 5
ABC       02    
XYZ       02    
LMN       01      1  'should be 2   

So far, I've come up with this.

=SUMPRODUCT(($B$2:$B$38705=B2)*(M2>$M$2:$M$38705))+countifs(B2:B38705=B2,M2:M38705=M2)

What have I done wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栩栩如生 2025-01-25 07:49:46

好消息是,您可以丢弃 sumproduct函数并用一对 countifs函数。 Countifs可以使用完整的列引用而毫无损害,并且即使Sumpropropoduct Cell范围仅限于数据的范围,也比Sumpropraptuct更有效。

在N2作为标准功能中,

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

根据需要填写。

” net/anlsh.png“ alt =” rank_unique_subgroups_sample_data“>

//i.sstatic.net/gsetu.png“ alt =” rank_unique_subgroups_groups_a滤波结果“> > “

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.

      rank_unique_subgroups_sample_data

  Filtered Results

     rank_unique_subgroups_group_A filtered results rank_unique_subgroups_group_B_ filtered results rank_unique_subgroups_group_C filtered results

季末如歌 2025-01-25 07:49:46

基于 OP 的解决方案

研究了您要求发布任何替代方案的帖子,我对基于您通过 SUMPRODUCT 函数的原始方法的解决方案感兴趣。
IMO这可以显示正确的方式为了艺术

应用方法

获取

  • a)所有当前ID与组值低于或等于当前值

    MINUS

  • b ) 具有相同组值的当前 id 的数量从当前行开始计数

    PLUS

  • c) 1 的增量

公式示例,例如在单元格 N5 中:

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

PS

当然,我也同意您更喜欢上面发布的解决方案:+)

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 :+)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文