简体   繁体   English

Excel计算多个工作表和列的平均值和中位数

[英]Excel Calculate Average and Median across multiple worksheets and columns

Looking for some Excel help. 寻找一些Excel帮助。 I have the following worksheets: 我有以下工作表:

WORKSHEET WEEK1
A-------|B------|C------|D------
NAME    |GAME A |GAME B |GAME C
JIM      10      15      12
BILL     12      10      5
TED      
PHIL     0       8       17

WORKSHEET WEEK2
A-------|B------|C------|D------
NAME    |GAME D |GAME F |GAME B
JIM      15      10      9
BILL     
TED      3       21      18 
PHIL     12      2       30

Basically, I'll have 10 worksheets (one per week). 基本上,我将有10个工作表(每周一个)。 We are tracking people's pinball scores over a series of weeks. 我们正在跟踪人们在一周内的弹球得分。 The games/scores will NOT be in the same order on the sheet week after week (20 machines, only six played per week). 一周又一周(20台机器,每周只有6台机器),游戏/分数在表格上的顺序不一样。

I need to calculate Average and Median for the machine across multiple worksheets, AND eliminate any missing or zeroed scores (so the average of 10,0,10 is 10, same for median, same for data missing/null). 我需要计算多个工作表中机器的平均值和中位数,并消除任何丢失或归零的分数(因此10,0,10的平均值为10,中位数相同,数据丢失/ null相同)。

I used this for the first week 我在第一周使用了这个

=MEDIAN(IF('1B'!L:L>0,'1B'!L:L))

And seemed to be just ducky, but am struggling getting this to be cross sheet in varied columns excluding blanks. 而且似乎只是令人讨厌,但我正在努力将其作为不同列中的交叉表,不包括空白。

I'm not opposed to having another sheet that looks through all of the worksheets and columns to find a match on the game title and then grab that column, calculate, done. 我并不反对使用另一张能够查看所有工作表和列的工作表来找到游戏标题上的匹配项,然后抓住该列,计算,完成。 But if I have to do this manual-ish, that's totally not a problem. 但如果我必须这样做手册,这完全不是问题。

I'm a C# developer, so I get code, I'm just dreadfully bad at Excel and the syntax makes me the tiniest bit sad. 我是一名C#开发人员,所以我得到了代码,我在Excel上的表现非常糟糕,语法让我感到非常难过。

UPDATE: The expected output is as follows: GAME A: Average: X, Median Y GAME B: Average: Z, Median N 更新:预期输出如下:游戏A:平均值:X,中位数Y游戏B:平均值:Z,中位数N

Thanks much! 非常感谢!

Assuming that: 假如说:

1) You have Excel 2007 or later 1)您有Excel 2007或更高版本

2) The data in each of the sheets to be queried occupies the range A1:D5 (with headers in row 1 and names in column A) 2)要查询的每个工作表中的数据占用范围A1:D5 (第1行中的标题和A列中的名称)

3) You put your choice of game (eg "GAME B") for which you wish to obtain the desired results in cell A1 of a sheet other than those being queried 3)您将您想要获得所需结果的游戏选择(例如“游戏B”)放在除被查询之外的工作表的单元格A1

First go to Name Manager ( Formulas tab) and make the following definition: 首先转到Name ManagerFormulas选项卡)并进行以下定义:

Name: SheetList 名称: SheetList

Refers to: ={"Sheet1","Sheet2","Sheet3"} 指: ={"Sheet1","Sheet2","Sheet3"}

(Or whatever happen to be the relevant sheet names in question.) (或者恰好相关的相关表格名称。)

The required array formula** for the average is then: 那么平均所需的array formula**是:

=AVERAGE(IFERROR(1/(1/N(INDIRECT(SheetList&TEXT(ROW(B2:D5)*10^5+TRANSPOSE(MODE.MULT(IF(T(INDIRECT(TRANSPOSE(SheetList)&TEXT(10^5+COLUMN(B2:D5),"!R0C00000"),0))=A1,COLUMN(B2:D5)),COLUMN(B2:D5))),"!R0C00000"),0))),""))

Replace AVERAGE with MEDIAN in the above to obtain the equivalent median for that game. 在上面用MEDIAN替换AVERAGE以获得该游戏的等效中位数。

Regards 问候

**Array formulas are not entered in the same way as 'standard' formulas. **数组公式的输入方式与“标准”公式的输入方式不同。 Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. 您只需按住CTRL和SHIFT键,然后按ENTER键,而不是按ENTER键。 If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself). 如果你已经正确地完成了它,你会注意到Excel在公式周围放置了大括号{}(尽管不要尝试自己手动插入这些)。

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

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