简体   繁体   English

打破 RANKX Powerpivot 公式的联系

[英]Break ties in RANKX Powerpivot formula

I can rank my data with this formula, which groups by Year, Trust and ID, and ranks the Areas.我可以用这个公式对我的数据进行排名,它按年份、信任和 ID 分组,并对区域进行排名。

rankx(
      filter(Table,
          [Year]=earlier([Year])&&[Trust]=earlier([Trust])&&[ID]=earlier([ID])),
              [Area], ,1,Dense)

This works fine - unless you have data where the same Area appears more than once in the same group, whereupon it gives all rows the rank of 1. Is there any way to force unique rank values?这工作正常 - 除非您有相同区域在同一组中出现多次的数据,因此它给所有行的排名为 1。有没有办法强制唯一的排名值? So two rows that have the same Area would be given the rank of 1 and 2 (in an arbitrary order)?那么具有相同区域的两行将被赋予 1 和 2 的等级(以任意顺序)? Thank you for your time.感谢您的时间。

Assuming you don't have duplicate rows in your table, you can add another column as a tie-breaker in your expression.假设您的表中没有重复的行,您可以在表达式中添加另一列作为决胜局。

Suppose your table has an additional column, [Name] , that is distinct between your multiple [Area] rows.假设您的表有一个额外的列[Name] ,它在您的多个[Area]行之间是不同的。 Then you could write your formula like this:然后你可以这样写你的公式:

= RANKX(
      FILTER(Table,
          [Year] = EARLIER([Year]) && 
          [Trust] = EARLIER([Trust]) &&
          [ID] = EARLIER([ID])),
      [Area] & [Name], , 1, Dense)

You can append as many columns as you need to get the tie-breaking done.您可以根据需要追加尽可能多的列来完成打破平局。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM