在 PowerPIvot/DAX 中获取 PERCENTRANK.INC

Getting the PERCENTRANK.INC in PowerPIvot/DAX

我的任务是将工作表从标准 Excel 转换为 PowerPivot。但是,我遇到了 DAX 中不可用的 PERCENTRANK.INC 函数的障碍。我已经接近于使用公式复制它,但在计算上存在明显差异。

有谁知道Excel如何计算PERCENTRANK.INC()?

Formula in cell D2: =(COUNT($A:$A)-B2)/(COUNT($A:$A)-1)
Formula in cell B2: =RANK.EQ(A2,$A:$A,0)
Formula in cell C2: =PERCENTRANK.INC($A:$A,A2)

编辑:

令我感到奇怪的是,有这么多 "standard" 方法来计算 PERCENTRANK 结果却略有不同。

使用你的 1,2,3,4,4,6,7,8,9 9 数字集的例子,取决于我使用的 "authority",third 值(3) 的排名百分比为 25.0%, 27.0%, 27.8% or 30.0%

显然,我们会选择能够提供您想要的结果的那个,匹配 PERCENTRANK.INC

   PERCENTRANK.INC is calculated as:

          [count of values lower than the given value]

                             ÷

    [count of all values in the set excluding the given value]

所以,如果我们的1,2,3,4,4,6,7,8,9范围在A1:A9,我们可以在B1中使用这个公式:

=COUNTIF($A:$A,"<"&A1)/(COUNT($A:$A)-1)

...然后复制或"fill" 下来查看结果:

0.0%, 12.5%, 25.0%, 37.5%, 37.5%, 62.5%, 75.0%, 87.5%, 100.0%

原答案

I think you just want to calculate the PERCENTRANK for current row value. Based on the logic for PERCENTRANK, we can add a RANK column in table and achieve same logic based on this column.

Create a Rank column.

Rank = RANKX(Table6,Table6[Value])

Then create the PctRank based on the Rank column.

PctRank = (COUNTA(Table6[Name])-Table6[Rank])/(COUNTA(Table6[Name])-1)

(Source)

此处供参考的是基于 ashleedawg 答案的 DAX 公式,其中包括忽略其中没有值的单元格。

=ROUNDDOWN(COUNTROWS(FILTER('Lookup_Query','Lookup_Query'[Entrances]<EARLIER('Lookup_Query'[Entrances]) && ISBLANK('Lookup_Query'[Entrances])=FALSE()))/(COUNTROWS(FILTER('Lookup_Query',ISBLANK('Lookup_Query'[Entrances])=FALSE()))-1),3)