简体   繁体   English

Excel将平均行数转换为数组公式

[英]Excel average rows to array formula

I want to take the average of rows which would result in a column (array). 我想获取将导致列(数组)的行的平均值。 Example input: 输入示例:

3 4 3 4

4 4 4 4

4 6 4 6

With an array formula I want to create: 使用数组公式,我要创建:

3.5 3.5

4 4

5

The average is the sum of numbers divided by the count of that numbers. 平均值是数字的总和除以该数字的计数。 So first add them (A1:A3+B1:B3) 所以首先添加它们(A1:A3 + B1:B3)
3+4 = 7 3 + 4 = 7
4+4 = 8 4 + 4 = 8
4+6 = 10 4 + 6 = 10
Then divide by the number of numbers(/2): 然后除以数字数(/ 2):
7/2 = 3.5 7/2 = 3.5
8/2 = 4 8/2 = 4
10/2 = 5 10/2 = 5

{=(A1:A3+B1:B3)/2}

edit after comment from op: 在发表评论后进行编辑:
formula for addition without adding column manually from https://productforums.google.com/forum/#!topic/docs/Q9x44sclzfY 无需手动从https://productforums.google.com/forum/#!topic/docs/Q9x44sclzfY添加列的添加公式

{=mmult(A1:B3,sign(transpose(column(A1:B3))))/Columns(A1:B3)}

This is one way to do that in Excel 这是在Excel中执行此操作的一种方法

=SUBTOTAL(1,OFFSET(A1:B3,ROW(A1:B3)-MIN(ROW(A1:B3)),0,1))

OFFSET supplies an "array of ranges", each range being a single row, and SUBTOTAL with 1 as first argument, averages each of those ranges. OFFSET提供“范围数组”,每个范围为一行, SUBTOTAL以1作为第一个参数,对每个范围取平均值。 You can use this in another formula or function or entered in a range on the worksheet. 您可以在另一个公式或函数中使用它,也可以在工作表中的某个区域中输入它。

The advantage over Siphor's suggestion with MMULT is that this will still work even with blanks or text values in the range (those will be ignored) 相对于Siphor的MMULT建议,其优点在于,即使空白或文本值在此范围内,这仍然可以使用(那些将被忽略)

If first column is A and the second is B, then enter this formuls in column C: 如果第一列是A,第二列是B,则在C列中输入以下公式:

=AVERAGE(A1,B1)

and extend it to the last row 并将其扩展到最后一行

Also you can use a range if you have more than 2 columns (this function allows for some cells to be empty): 如果您有多于2列,也可以使用范围(此功能允许某些单元格为空):

 =AVERAGE(A1:F1)

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

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