获取Excel中的平均排名。

huangapple go评论71阅读模式
英文:

Get the average rank in excel

问题

我有一个基于日期的列列表

property | 2023-04-10 | 2023-04-11 | 2023-04-12
A        |    0:10    |    0:20    |   0:30
B        |    0:05    |    0:12    |   0:35
C        |    0:02    |    0:10    |   0:40

我想计算一个具有平均排名的列,即

property | average_rank
A        |     (1+1+3)/3
B        |     (2+2+2)/3
C        |     (3+3+1)/3

如何在Excel中实现这一点,而且某些单元格有空白条目,这种情况下,我不希望在计算平均排名时考虑该单元格

有数百列,所以我不能一个一个地输入它们到平均函数中。

英文:

I have a list of columns based on date

property | 2023-04-10 | 2023-04-11 | 2023-04-12
A        |    0:10    |    0:20    |   0:30
B        |    0:05    |    0:12    |   0:35
C        |    0:02    |    0:10    |   0:40

I want to compute a column which has average rank, that is

property | average_rank
A        |     (1+1+3)/3
B        |     (2+2+2)/3
C        |     (3+3+1)/3

how do I achieve this in excel, also some of the cells have blank entries, in that case I would not like consider that cell while calculating the average rank

there are 100s of columns so I cannot enter them one by one in the average function

答案1

得分: 2

以下是您提供的内容的翻译:

最新的 Microsoft-365 功能组合可能会起作用。

=BYROW(
MAP(B2:D4,LAMBDA(x,RANK(x,INDEX(B2:D4,,COLUMN(x)-COLUMN(A2))))),
LAMBDA(rw,AVERAGE(rw))
)

我们可以使用以下公式避免使用 RANK() 函数。

=BYROW(
MAP(B2:D4,LAMBDA(x,XMATCH(x,SORT(CHOOSECOLS(B2:D4,COLUMN(x)-MIN(COLUMN(B2:D4))+1),,-1)))),
LAMBDA(rw,AVERAGE(rw))
)

获取Excel中的平均排名。

英文:

Combination of latest functions of Microsoft-365 may work.

=BYROW(
MAP(B2:D4,LAMBDA(x,RANK(x,INDEX(B2:D4,,COLUMN(x)-COLUMN(A2))))),
LAMBDA(rw,AVERAGE(rw))
)

We can avoid using of RANK() function using the following formula.

=BYROW(
MAP(B2:D4,LAMBDA(x,XMATCH(x,SORT(CHOOSECOLS(B2:D4,COLUMN(x)-MIN(COLUMN(B2:D4))+1),,-1)))),
LAMBDA(rw,AVERAGE(rw))
)

获取Excel中的平均排名。

答案2

得分: 2

=LET(in,B2:D4,BYROW(MAKEARRAY(ROWS(in),COLUMNS(in), LAMBDA(i,j,
RANK(INDEX(in,i,j),INDEX(B2:D4,,j)))),LAMBDA(z, AVERAGE(z))))

注意

在Excel for Web下,我测试了您可以使用INDEX(in,,j)而不是INDEX(B2:D4,,j)。正如@JosWoolley在评论中指出的,使用名称ìn测试在O365的桌面版本下会产生#CALC!(嵌套数组错误)。我还测试了这个桌面版本:Microsoft 365 Apps for Enterprise Version 2304 (Build 16327.20214 Current Channel)。Microsoft更新/发布渠道政策可能存在的一个可能的错误或不一致性。我在Microsoft Feedback社区发布了此问题,这是链接,如果您想投票支持的话。

避免此错误并继续使用名称in的另一种解决方法是创建一个LAMBDA(B2:D4)函数,即“thunking the range”,并将其命名为in,然后引用它。这确保了公式更容易维护(如果需要更新范围,则只需在一个地方更新)。例如:

=LET(in, LAMBDA(B2:D4), BYROW(MAKEARRAY(ROWS(in()),COLUMNS(in()), LAMBDA(i,j,
 RANK(INDEX(in(), i,j), INDEX(in(),,j)))),LAMBDA(z, AVERAGE(z))))

注意我们如何调用它:in()

这是输出:
获取Excel中的平均排名。

MAKEARRAY遍历输入(in)的所有元素,并计算相对于in的第j列的给定元素(ij)的RANK。然后我们在MAKEARRAY结果上调用BYROW来计算每行的平均值。

英文:

You can try the following, assuming no Excel version constraints as per the tag listed in the question:

=LET(in,B2:D4,BYROW(MAKEARRAY(ROWS(in),COLUMNS(in), LAMBDA(i,j,
 RANK(INDEX(in,i,j),INDEX(B2:D4,,j)))),LAMBDA(z, AVERAGE(z))))

Note

Under Excel for Web, I tested you can use INDEX(in,,j) instead of INDEX(B2:D4,,j). As @JosWoolley pointed out in the comment section, testing the formula using the name ìn produces a #CALC! (Nested array error) for desktop under O365. I tested also for this desktop version: Microsoft 365 Apps for Enterprise Version 2304 (Build 16327.20214 Current Channel). A possible bug or inconsistency in Microsoft update/release channel policy. I posted this issue in the Microsoft Feedback community, here is the link, in case you would like to vote for it.

Another workaround to avoid this error and keep using the name in, is to create a LAMBDA(B2:D4) function, i.e. "thunking the range" and name it in, then to refer it. It ensures the formula is easier to maintain (if you need to update the range, update it in one place only). For example:

=LET(in, LAMBDA(B2:D4), BYROW(MAKEARRAY(ROWS(in()),COLUMNS(in()), LAMBDA(i,j,
 RANK(INDEX(in(), i,j), INDEX(in(),,j)))),LAMBDA(z, AVERAGE(z))))

Notice how we call it: in().

Here is the output:
获取Excel中的平均排名。

MAKEARRAY iterates over all elements of the input (in) and calculate the RANK for a given element (i,j) with respect to column j of in. Then we invoke BYROW on the MAKEARRAY result to calculate on each row the average.

huangapple
  • 本文由 发表于 2023年5月18日 12:15:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/76277695.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定