0

I am using Excel 2003 and am trying to average every two rows of data in one column, starting from A1 and ending in A4, for example,

1 
2 
1 
2 

I try to do this average on the B1 column/row as follows (based on this info)

=AVERAGE(IF(MOD(ROW(A1:A4),2)=0,A1:A4))

However, when doing the above, B1 returns a 0, even though I intended to get a 1. What would be the best way to make this kind of averaging work?

3 Answers 3

0
=AVERAGE(IF(MOD(ROW(A1:A4),2)=0,A1:A4))

The above formula is an array formula. To finalize it you need to press ++ simultaneously; not just . This has also been abbreviated as CSE.

When you do this correctly, excel will wrap the formula in braces (e.g. { and }) like this:

{=AVERAGE(IF(MOD(ROW(A1:A4),2)=0,A1:A4))}

You do not type these braces in yourself; they are added automatically when a formula is entered as an array formula.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, I was typing in my own answer at about the same time. I also found that in addition to your post, there needed to be a -1 after the ROW(A1:A4).
0

The solution to the question was as follows:

{=AVERAGE(IF(MOD(ROW(A1:A4)-1,2)=0,A1:A4))}

where the {} appears after pressing ++ due to it being an array formula (cannot type that in manually). The -1 is the offset based on where the data starts, and depending on the modulus operation, since MOD(ROW(A1),2) was 1,

i.e.: if my data instead started on A27, and I instead wanted to average values in every 4 rows, then MOD(ROW(A27),4) would return a 3 and the formula would correspondingly be offset by -3.

1 Comment

Side note: If attempting the same thing in Libreoffice Calc (free excel clone), typing ctrl+shift+enter again on an existing array formula may not work; You may need to either include a change to the formula or add a space character to end of the formula then do ctrl+shift+enter, as per a 2011 bug report: bugs.documentfoundation.org/show_bug.cgi?id=38014.
0

You could avoid array formulas using the below:

=IF((INT(ROW()/2)=ROW()/2)=TRUE,AVERAGE((A1,OFFSET(A1,-1,0))),"")

Image:

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.