简体   繁体   English

将INDEX / MATCH与多个条件和多个匹配项并置

[英]Concatenating INDEX/MATCH with multiple criteria and multiple matches

I am using Excel to track a team game where players are divided into teams and subteams within teams. 我正在使用Excel跟踪团队游戏,在该游戏中,玩家分为团队和团队内的子团队。 Each player within a subteam scores a certain number of points, and I would like to have a summary string for each player with the number of points other players in the same subteam scored. 一个子团队中的每个球员都获得一定数量的分数,我想为每个球员提供一个汇总字符串,以及同一子团队中其他球员的得分。

Example: 例:

A         B       C          D
PLAYER    TEAM    SUBTEAM    POINTS
Alice     Red     1          70
Bob       Red     1          20
Charlie   Red     1          10
Dave      Red     2          70
Erin      Red     2          30
Frank     Blue    1          55
Grace     Blue    1          45

My desired output looks like this: 我想要的输出如下所示:

A         B       C          D        E
PLAYER    TEAM    SUBTEAM    POINTS   SUMMARY
Alice     Red     1          70       Bob:20, Charlie:10
Bob       Red     1          20       Alice:70, Charlie:10
Charlie   Red     1          10       Alice:70, Bob:20
Dave      Red     2          70       Erin:30
Erin      Red     2          30       Dave:70
Frank     Blue    1          55       Grace:45
Grace     Blue    1          45       Frank:55

The furthest I was able to go is a combination of CONCATENATE, INDEX, and MATCH in an array formula: 我能走的最远的是数组公式中CONCATENATE,INDEX和MATCH的组合:

{=CONCATENATE(INDEX($A$2:$A$8,MATCH(1,(C2=$C$2:$C$8)*(B2=$B$2:$B$8),0)), ":", INDEX($D$2:$D$8,MATCH(1,(C2=$C$2:$C$8)*(B2=$B$2:$B$8),0)))}

This unfortunately just outputs a summary for the first player in the subteam: 不幸的是,这只是输出子团队中第一个玩家的摘要:

A         B       C          D        E
PLAYER    TEAM    SUBTEAM    POINTS   SUMMARY
Alice     Red     1          70       Alice:70
Bob       Red     1          20       Alice:70
Charlie   Red     1          10       Alice:70
Dave      Red     2          70       Dave:70
Erin      Red     2          30       Dave:70
Frank     Blue    1          55       Grace:45
Grace     Blue    1          45       Grace:45

What I need to do now is: 我现在需要做的是:

  1. Excluding the player for the summary (I don't want Alice in the summary for Alice, but only Bob and Charlie) 不包括摘要玩家(我不希望爱丽丝加入爱丽丝的摘要中,而只希望鲍勃和查理)
  2. Getting it to work for multiple matches (there can be an arbitrary number of players in each subteam) 使它可以用于多个比赛(每个子团队中可以有任意数量的球员)
  3. Getting CONCATENATE to work with an unknown number of strings (because as said above, there can be an arbitrary number of players in each subteam). 让CONCATENATE使用未知数量的琴弦(因为如上所述,每个子团队中可以有任意数量的玩家)。

Ideas appreciated! 想法表示赞赏!

I put together a helper column that concatenates each player/points and the TEXTJOINIFS from TEXTJOIN for xl2010/xl2013 with criteria for the desired results. 我整理了一个帮助列,其中将每个玩家/积分和TEXTJOIN的TEXTJOINIFS(用于xl2010 / xl2013)与期望结果的条件连接在一起

在此处输入图片说明

Unfortunately Excel (prior to Excel 2016) cannot conveniently join text. 不幸的是,Excel(Excel 2016之前的版本)无法方便地联接文本。 The best you can do (if you want to avoid VBA) is to use some helper cells and split this "Summary" into separate cells. 最好的办法(如果要避免使用VBA)是使用一些辅助单元并将此“摘要”拆分为单独的单元。

See example below. 请参见下面的示例。 The array formula in cell E4 is dragged to cell J10 . 单元格E4的数组公式被拖动到单元格J10

= IFERROR(INDEX($A$4:$D$10,MATCH(SMALL(IF(($B$4:$B$10=$B4)*($C$4:$C$10=$C4)*($A$4:$A$10<>$A4),
  ROW($A$4:$A$10)),E$3),ROW($A$4:$A$10),0),MATCH(E$2,$A$1:$D$1,0)),"")

Note this is an array formula, so you must press Ctrl + Shift + Enter instead of just Enter after typing this formula. 请注意,这是一个数组公式,因此在键入此公式后,必须按Ctrl + Shift + Enter,而不仅仅是Enter

在此处输入图片说明

Of course, in this example I assume 3 players. 当然,在此示例中,我假设有3位玩家。 Your requirement of arbitrary amount of players cannot be met with formulas alone, but you can just extend the "Summary" section over to the right as far as necessary. 单靠公式不能满足您对任意数量玩家的要求,但是您可以根据需要将“摘要”部分扩展到右侧。

If you really wanted to, you could even concatenate the "Summary" rows to form a single cell, eg something like: 如果确实需要,甚至可以将“摘要”行连接起来以形成单个单元格,例如:

= CONCATENATE(E4,": ",F4,", ",...)

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

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