Split data and find average Excel - excel-formula

I have an excel file with a 1000 rows of data. I want to split the data in a way that I have 40 arrays of 25 rows each and get the average of the data. how do I do this?

These solutions are Non-Volatile
Assuming the data is located in A1:A1000
Solution 1: Showing only the Average of the 40 sub ranges (see fig. 1)
Array Number: Enter this formula in B2, copy till B41 then copy\paste the values
=SUM(1,B1)
Averages: Enter this formula in C3 and copy till C41
=AVERAGE(INDEX($A$1:$A$1000,($B2*25)-24):INDEX($A$1:$A$1000,($B2*25)))
Solution 2: Shown the 40 sub ranges and the averages (see fig. 2):
Array Number: Enter this formula in B3, copy till B27 then copy\paste the values
=SUM(1,B1)
Enter this formula in C2, copy till AP2 then copy\paste the values
=SUM(1,B2)
Arrays: Enter this formula in C3, copy till C27 the copy till column AP
=INDEX($A$1:$A$1000,(C$2*25)-25+$B3)
Averages: Enter this formula in C1 then copy till AP1
=AVERAGE(C$2:C$27)

Assuming that:
Your data is in column A, starting from the top
You want your output in columns D and later
I would propose the following:
You leave cell C1 blank
In cell D1, you enter the formula = C1 +1
In cell C2, you enter the formula = C1 +1
Now you can drag down column C untill you get to 25 rows and row 1 untill you get to 40 columns
In the matrix you just created, cell D2 is the first data point. In this cell, you enter the formula = OFFSET( $A$1, 40 * ( D$1 - 1 ) + $C2 - 1, 0 ), which you can now drag down and across.
The offset function takes the cell that is i rows below and j rows to the right of the first argument (in this case $A$1). we don't need any column offset, so the third argument is 0. The second argument looks at the column number of your matrix to see which sub-array it's looking at ("40 * ( D$1 - 1 )") and to the row number of your matrix to see which entry within the sub-array it should take ("$C2 - 1"). The "-1" is just because we started counting at 1 instead of 0.
For the averages, you can just use the = AVERAGE() function for each sub-array.
To make it a bit clearer, you can take this image as an example. The = RANDBETWEEN() function in column A was just for testing purposes.

Related

Need help in excel formulas

I have formulas for the top 4 rows formula is as follows row 1) C1= A1+B1 row 2 ) C2=A2+B2 row 3) C3=A3+B3 row 4) C4=C3/C1 and the next row is blank ie C5 post which the same continues 4 rows has formula and the 5th row is blank I have a huge data how to copy the formula below please help
Am struck please someone assist
I have skipped the blanks and copied the first four rows selected the below rows and pasted I need any other alternative either by formula or by copy paste
Cell C1
= IFS(MOD(ROW(),5)=0, "", MOD(ROW(),5)=4, OFFSET(C1, -1, 0)/OFFSET(C1, -3, 0), TRUE, A1+B1)
You can calculate all your data using that formula simply. Just double-click or drag the fill handle of cell C1 down to copy the formula.
The easiest way to do this on a very large scale is to just have ONE and ONLY one formula that applies to all cells, so you are copying it all the way down the sheet one time.
I'd do this by looking at ROW() to get the row number, and more specifically, using MOD(ROW(),5) to get a row index that goes 0-4, with 0 being the blank row.
This formula will look back up to previous rows so you will have to "prime the pump" for the first 3 rows manually:
Cell C1 will be =A1+B1
Cell C2 will be =A2+B2
Cell C3 will be =A3+B3
Cell C4 will be =SWITCH(MOD(ROW(),5),1,A4+B4,2,A4+B4,3,A4+B4,4,C3/C1,0,"")
Then copy this cell, C4, down the entire length of the sheet.
My specific formula assumes there's no headers and the values start in row 1.
If not, you just have to move the formulas to the right SWITCH indexes 0-4.

Stop counting when empty row is found

I have a table in which in one cell I display the sum of other cells =SUM(I57: I67). When I copy
the row containing this formula, it is not adapted, is calculated the whole amount for
the next 10 rows.
How to adjust the formula to calculate the sum of the values from cells until empty cell?
So in cell N46 the formula is =SUM (I46:I56)
As I copied the rows 46, 47 and 48 the formula of cell N57 is =SUM (I57:I67)
You can use following array formula:
{=SUM(A1:INDEX(A1:$A$10000,MATCH(TRUE,ISBLANK(A1:$A$10000),0)))}
For an array end address (i.e $A$10000) you can use any address larger than the last cell used.
Array formula after editing is confirmed by pressing ctrl + shift + enter

How to copy data from one cell to another - depending on the cell next to it?

I'm trying to:
In cell C3, search Column J to find an identical match of B3, then copy the data from Lx.
In cell D3, Search Column J to find an identical match of B3, then copy the data from Mx.
There are 10285 rows of data.
I have tried several IF and VLOOKUP statements.
In the group of columns, J:L, L is the fourth column, so use 4 in VLOOKUP:
Formula for C3:
=VLOOKUP($B3,$J:L,3,FALSE)
D3 is the same, but with 4 instead of 3 to get M.
If you want to get fancy and have the formula copy nicely across columns, you can use the COLUMN() function to help calculate the 3s and 4s:
Formula for C3:
=VLOOKUP($B3,$J:L,COLUMN(L3)-COLUMN($J3)+1,FALSE)
Then when you copy that from C3 to D3, the L becomes M and the column calculation produces 4 instead of 3.

Summing result of formula applied to rows

I have a column of numbers and would like to summarize the result of a formula applied to each row.
For example, if my formula is to square the cell value, in the following table I would like B1 to represent A1^2 + A2^2 + A3^2.
A B
- -
1 14
2
3
Is this possible without creating a column to store the result of the formula for each row before summing (i.e. here, a column containing 1, 4, 9)?
For your example:
=SUM((A1:A3)^2)
But here is the key: enter it as an array formula with Ctrl+Shift+Enter. It will add braces to it and should work.
It should look like this after pressing Ctrl+Shift+Enter:
{=SUM((A1:A3)^2)}
For summing squares of range values, please use this formula =SUMSQ(A2:A80).
So if you have data in Column A, put above formula in cell B2.

Copy from sheet 1 to sheet 2 every 50th row

I need to copy data from tab1(sheet 1) to tab2(sheet2) every 50 lines. I can get it to do it manually, but when I try and copy the formula down after setting up a few cells it gives me random cells not every 50 like what was in the previous formulas.
If you place this formula in row 1 of any column it will return the proper pattern (2, 52, 102...)
=INDIRECT("A" & 2 + 50*(ROW()-1))
However note that INDIRECT is a volatile formula. This will slow your workbook if you have a lot of calculations and a lot of calls to INDIRECT().
in sheet2!A1, use the following formula, then copy down:
=OFFSET(Sheet1!$A$1,1+(ROW()-1)*50,0,,)
You could use Index and Row to achieve this..
for example the following formula in column B
=INDEX(A:A,(ROW()-1)*50+2,0)
will return back
B1 = A2
B2 = A52
B3 = A102
....

Resources