Average of every 5 cells in a column

Discuss the spreadsheet application
Post Reply
hit
Posts: 4
Joined: Mon Aug 24, 2015 7:58 pm

Average of every 5 cells in a column

Post by hit »

hello
i have numbers in the cells of column A and i want to calculate the average of every 5 cells and put it in column B
so the first 5 numbers from column A will give a number to be put in column B and so on

i found several ways through google but i did not manage it to make it work

any help would be much appreciated

thank you
OpenOffice 4.1 on Windows
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Average of every 5 cells in a column

Post by RusselB »

If your numbers in column A start on row 1, then in column B .. presuming you want the first five consecutive numbers .. you would enter

Code: Select all

=average(A1:A5)
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
hit
Posts: 4
Joined: Mon Aug 24, 2015 7:58 pm

Re: Average of every 5 cells in a column

Post by hit »

yes but after that how is it going to go from cell A6:A10 and then from A11:A15 and so on
OpenOffice 4.1 on Windows
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Average of every 5 cells in a column

Post by RusselB »

If the formula for my example is in B1, then you can copy that formula and paste it in B6
If you want the updated formula to be in B2, then I suggest just entering the formula with the different range.
If you want the updated formula to be in B2 but don't want to have to enter the range manually (which can get to be redundant), then you can copy & paste the formula through out column B, then delete the rows of column B that have averages for ranges you don't want.

These are the simplest ways of getting what you seem to be asking for. It is possible, using helper columns and much more complicated formulas, to have the row numbers automatically calculated.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
hit
Posts: 4
Joined: Mon Aug 24, 2015 7:58 pm

Re: Average of every 5 cells in a column

Post by hit »

well i have thousands of data in column A
=SUM(OFFSET($D$2,(ROW()-ROW($D$2))*5,0,5,1)) / 5

this is something i found through google that it is supposed to calculate the average every 5 cells and then i added a division by 5 to that so it would give the average
but it did not work on openoffice although other people testing it confirm that it works on office excel


i think i need something similar to the one above

thank you
OpenOffice 4.1 on Windows
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Average of every 5 cells in a column

Post by Villeroy »

Do not copy any formulas you do not understand.

Add a helper column, say X. If row #1 has column labels and the numeric data reside in D2:D1000, put
=MOD(ROW();5) in column X
and
=SUMIF($X$1:$X$1000;2;$D$1:$D$1000) / COUNTIF($X$1:$X$1000;2)
divides the sum of all D values with row number 2 by the count of rows with row number 2.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
hit
Posts: 4
Joined: Mon Aug 24, 2015 7:58 pm

Re: Average of every 5 cells in a column

Post by hit »

just tried it and it does not work the way i described :(
it does not show the average for every 5 cells
it only shows the same number for all
(i did not understand why you divide by 2 in your formula though)
OpenOffice 4.1 on Windows
User avatar
Villeroy
Volunteer
Posts: 31279
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Average of every 5 cells in a column

Post by Villeroy »

blah.ods
average every 5th row
(12.33 KiB) Downloaded 271 times
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Average of every 5 cells in a column

Post by RusselB »

I used my formula at viewtopic.php?f=9&t=76889&hilit=+subtotal#p350567 as a basis for the formula in column D on the attached spreadsheet
Attachments
temp 1.ods
(16.76 KiB) Downloaded 174 times
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
Post Reply