简体   繁体   中英

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

4 4

4 6

With an array formula I want to create:

3.5

4

5

The average is the sum of numbers divided by the count of that numbers. So first add them (A1:A3+B1:B3)
3+4 = 7
4+4 = 8
4+6 = 10
Then divide by the number of numbers(/2):
7/2 = 3.5
8/2 = 4
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

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

This is one way to do that in 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. 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)

If first column is A and the second is B, then enter this formuls in column 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):

 =AVERAGE(A1:F1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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