楼主 lrlxxqxa |
Q:如何用多种方法实现RANK排序效果?
A:按照数据源中是否有重复分开来看这个问题; 先来看当数据不重复时,我们怎么做;
方法1数组公式- =SUM(N($B$2:$B$16>=B2))
方法2- =SUMPRODUCT(N($B$2:$B$16>=B2))
方法3数组公式- =COUNT(IF($B$2:$B$16>=B2,1))
方法4- =COUNTIF($B$2:$B$16,">="&B2)
方法5数组公式- =SUM(N(FREQUENCY(IF($B$2:$B$16>=B2,$B$2:$B$16),$B$2:$B$16)))
方法6数组公式- =MMULT(N($B$2:$B$16<=TRANSPOSE($B$2:$B$16)),ROW($B$2:$B$16)^0)
方法7数组公式- =ROUNDDOWN(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),)+1
方法8- =ROUNDDOWN(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),)+1-(MIN($B$2:$B$16)=B2)
方法9- =ROUNDUP(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),)+(MAX($B$2:$B$16)=B2)
方法10- =INT(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)))+1-(MIN($B$2:$B$16)=B2)
方法11- =TRUNC(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)))+1-(MIN($B$2:$B$16)=B2)
方法12- =CEILING(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),1)+(MAX($B$2:$B$16)=B2)
方法13- =FLOOR(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),1)+1-(MIN($B$2:$B$16)=B2)
再来看当数据中有重复时,下述13个公式返回结果会如何变化,以及如何调整才能和RANK排序结果一致:
当数据源中存在重复值时,上述公式需要进行如下调整(顺序一一对应):
2数组- =SUM(N($B$2:$B$16>B2))+1
3- =SUMPRODUCT(N($B$2:$B$16>B2))+1
4数组- =COUNT(IF($B$2:$B$16>B2,1))+1
5 =COUNTIF($B$2:$B$16,">"&B2)+1 6数组- =SUM(FREQUENCY(IF($B$2:$B$16>B2,$B$2:$B$16),$B$2:$B$16))+1
7区域数组- =MMULT(N($B$2:$B$16<TRANSPOSE($B$2:$B$16)),ROW($B$2:$B$16)^0)+1
8- =ROUNDDOWN(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),)+2-COUNTIF($B$2:$B$16,B2)-(MIN($B$2:$B$16)=B2)
9- =ROUNDUP(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),)-COUNTIF($B$2:$B$16,B2)+1+(MAX($B$2:$B$16)=B2)
10- =INT(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)))+2-COUNTIF($B$2:$B$16,B2)-(MIN($B$2:$B$16)=B2)
11- =TRUNC(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),)+2-COUNTIF($B$2:$B$16,B2)-(MIN($B$2:$B$16)=B2)
12- =CEILING(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),1)-COUNTIF($B$2:$B$16,B2)+1+(MAX($B$2:$B$16)=B2)
13- =FLOOR(COUNTA($B$2:$B$16)*(1-PERCENTRANK($B$2:$B$16,B2)),1)+2-COUNTIF($B$2:$B$16,B2)-(MIN($B$2:$B$16)=B2)
请自行对比。 排序多种方法.rar 排序解析.rar |