I am trying to figure out how to average 4 x 4 groups of cells in my spreadsheet across a very large data set. I've tried using OFFSET with a cell range (e.g. B2:E5) but I haven't had success (I don't even know if you can use a range for the reference with OFFSET). This is my first time tackling a problem like this, so any advice would be welcome! A portion of the data set is attached to give an idea of the ranges I would like to average.
If the data was in B2:Q17 you could use this complicated looking formula to return the average for each 4*4 block.
=AVERAGE(INDEX($B$2:$Q$17,(ROWS($2:2)-1)*4+1,(COLUMNS($R:R)-1)*4+1):INDEX($B$2:$Q$17,(ROWS($2:2)-1)*4+4,(COLUMNS($R:R)-1)*4+4))
You would copy this across and down and it could go anywhere on a sheet.
You can use INDEX to refer to a range derived from values fro TopLeft and BottomRight corners, in the form
INDEX(DataRange, TopRow, LeftCol):INDEX(DataRange, BottomRow, RightCol)
Then wrap that in AVERAGE(...)
To demonstrate
=AVERAGE(INDEX($B$7:$AH$903,B1,B2):INDEX($B$7:$AH$903,B3+B1-1,B4+B2-1))
Note: INDEX has the advantage over OFFSET in that it's non-volatle
Related
Without using VBA macros, is it possible to dynamically set the range of a graph?
I have a table like this:
I want to now create a graph with merely the "valid" amounts of 2,3,4 and 5 as bar chart, say. These valid ranges can change however to 3,4 and 5 say. The valid numbers are always consecutive. so I just need the beginning and end.
I've looked into index, match, and offset, and I just don't get how to accomplish this exactly.
Thanks in advance.
My answer in a nutshell as I have to leave in a few minutes. (I can add details later, if you are interested).
As far as I know, Excel charts do neither allow range names or formula as input, which makes it difficult to set a dynamic range without a VBA macro.
However, if you are only interested in a chart that grows and shrinks with the data, you can use a XY chart do achieve the desired result.
Formulas:
D2: =IF(COUNTBLANK(A2)=1,#NA,COUNTIFS(D$1:D1,">=0")+1)
E2: =D2
F2: =IF(COUNTBLANK(C2)=1,#NA,0)
G2: =IF(COUNTBLANK(C2)=1,#NA,C2)
Chart properties
Just create the maximum number of rows (here 7)
Set the stroke/line width to 30.
Ajust the x-axis to start with 0.5.
Note: Screenshots were made with a German Excel version.
Downsite: The x-axis labels cannot be adjusted easily.
So I'm not a fan of VBA and I recently learned that OFFSET can be used with COUNTA to flashfill a range as far at it is as long as you aim for a longer range than you have data. Now I want to be able to achieve this both for columns and rows at the same time, where the rows are averaged. Could this be done? I am banging my head against the wall to find some logic to do it, but can only manage to combine it in a way that multiplies the rows with the number of the column.. which is not desired, of course.
I have posted a Minimal Reproducible Example in Excel Online:
https://onedrive.live.com/view.aspx?resid=63EC0594BD919535!1491&ithint=file%2cxlsx&authkey=!ALmV0VtFb7QZCvI
If you see Cell J9 and J11 you will see what I want to combine. The three rows in J11 and down, I want to average in J10, and spill/flashfill (like J9 and 11 does automatically because of the formula already) them from to the right, for as many columns as there data in the range A1-G4..
So I have raw data of numbers with titles in A1-G4, and by writing =OFFSET($A$1:$A$1,0,0,1,COUNTA($A$1:$EV$1)-1) in J9 I get all the titles of the columns filled from left to right, and by writing =OFFSET($A$1,1,0,COUNTA($A:$A)-1) in J11 I get the rows of the first column filled from top to bottom. They can also be combined, by writing OFFSET(Days,1,0,COUNTA($A:$A)-1,COUNTA(Days)), where "Days" is =OFFSET($A$1:$A$1,0,0,1,COUNTA($A$1:$EV$1)-1) (in a named range for readability) or OFFSET($A$1:$A$1,0,0,1,COUNTA($A$1:$EV$1)-1) without using a named range
As a thought, though I'm not sure how to implement it, maybe this could somehow be used in some form to get the column reference for the horizontal part in combination with =AVERAGE(OFFSET($A$1,1,0,COUNTA($A:$A)-1))
=MID(ADDRESS(ROW(),COLUMN()),2,SEARCH("$",ADDRESS(ROW(),COLUMN()),2)-2)
..found at https://superuser.com/questions/1259506/formula-to-return-just-the-column-letter-in-excel/1259507
Now, based on your explanation, here is the screenshot of my test:
Section A1:Exxx
I have converted that section into a Table, called «TblData», having numerous avantages:
It expands automatically without any additional efforts/formula
We can identify Data by its Columns attributed automatically by the Table [#1], [#2],[#3], [#4], [#5]
Section J9:N9
As a replica of the table name, I have used the following formula to retrieve it:
=INDEX(TblData[#Headers],1,COLUMN(A1)) '<--- This is for J9
=INDEX(TblData[#Headers],1,COLUMN(E1)) '<--- This is for N9
Section J11:Nxx
As a replica of the Table Content, I have used the following formula to populate the content:
=INDEX(TblData,ROW($A1),MATCH(J$9,TblData[#Headers],0)) '<--- This is on J11
=INDEX(TblData,ROW($A3),MATCH(N$9,TblData[#Headers],0)) '<--- This is on N13
Section J10:N10
Now this is the interesting part of the Average, so here is the formula I used for it:
=AVERAGE(TblData[1]) '<--- This is on J10
=AVERAGE(TblData[5]) '<--- This is on N10
NB: (1) Instead of using the Content below J10:N10, I prefer to reuse the Table as it expands automatically as more rows are added.
(2) Unless it is really necessary, I feel it is a double work as well to replicate again A1:Exxx from J9:Nxxx, because you can use the Table for whatever you need, with less maintenance.
Kindly find attached the file as well after I updated those items:
File Link: https://drive.google.com/open?id=1wRbpUxg0XLpfGqdvMF4fNKXDrL7xPPWs
We can correspond more below for further info. Hoping you to strech more your compentence :)
Sorry, mate, I can't figure out what you want to calculate. If it makes sense to add J9+J11 then you could just concatenate the two formulas in J9 and J11 with a plus sign. After much deliberation I decided to assume that your question is not one of formula but of formula-writing - "referencing" for short. Therefore I prepared this answer for you, hoping that it will prove helpful.
Building on your named range Days I suggest you create a dynamic named range Data with this formula.
[Data] =OFFSET(Sheet1!$A$1,0,0,COUNTA(Sheet1!$A:$A),COUNTA(Sheet1!$1:$1))
The range thus defined is dynamic in both directions. However, bearing in mind that OFFSET is volatile (slows down your worksheet) you may like to keep its use limited to this one formula and perhaps start the range at A2, but I shall tempt you to break the rule. Now you can use the INDEX function to refer to the Data range.
= INDEX(Data, [Row number], [Column number])
defines a single cell. But by setting either column or row to zero you can define an entire column or row. =INDEX(Data,0,1) defines column 1 of the Data range, =INDEX(Data,1,0) defines its first row.
=INDEX(OFFSET(Data,1,0),0,1) defines the first column of a range moved down by one row from its original position. I recommend the alternative and start the Data range from A2 and perhaps declare another range for the first row if needed.
=AVERAGE(INDEX(Data,0,1)) would draw the same average you already have in your sheet, provided that Data was defined starting at A2. For fun's sake, =AVERAGE(INDEX(OFFSET(Data,1,0),0,1)) would do the same without the change in the range's definition.
=COLUMN() returns the number of the column this formula resides in. So, you could enter =COLUMN()-6 in column G, copy to the right and get a count starting from 1. (You can do the same vertically with the ROW() function.) Applied to your formula, =AVERAGE(INDEX(Data,0,COLUMN()-6)) would return the average from column 1 if entered in column G, and from columns 2, 3 4, etc as copied to the right.
As I said, I don't understand enough of your request to bring this idea to a conclusion but I think that using the method described above will provide you with a tool to copy formulas into the table your sample has at its right. If you would elaborate on your requirement I might be able to assist more.
I've a question regarding columns and finding non zero values with there labels.
Hopefully the pictures will make my problem/struggle a bit better to understand.
Basically, there are columns to the right that show labels and hours that a team loaned in or out.
The values are found through a formula that shows per label the totals amount of hours spent.
Now I want to have on my overview page the two columns to the right with only labels showing the labels that contain hours. I've tried to use multiple if variables but that didn't seem to work :(
So at the end it should show something like this (I now manually typed the labels and data):
I did a quick recreation of your data structure to test this.
Using Array Formulas should get you the desired results in the current structure of your worksheet:
For range Loaned in you'd need the formula to be
=IFERROR(INDIRECT(ADDRESS(SMALL(IF($I$4:$I$14>0,ROW($4:$14),""),ROW(A1)),8)),"")
Where 8 is a reference to the return column. For the range directly to the right, you'd use the same formula, just adjust 8 to 9. And for range Loaned Out you'd need
=IFERROR(INDIRECT(ADDRESS(SMALL(IF($K$4:$K$23>0,ROW($4:$23),""),ROW(A1)),10)),"")
And for the range directly to the right you would again change the 10 to a 11. Again, both of these are array formulas, so they have to entered slightly differently. See the link for further assistance with array formulas.
This is not trivial. If you cannot work with filtering or programming, you should make use of matrix formulas. I include an example with two formulas: 1st in D1:D5, 2nd in F2:G5. Enter them with Ctrl+Shift+Enter. Also, you should use an extra column to determine the "valid" rows. (You could put it all in one formula, but it would look even more complicated.)
Sorry for German excel. Wennfehler = iferror, kkleinste = small, zeile = row, wenn = if, bereich.verschieben = range.offset.
I am looking for some help constructing a dynamic range formula that can skip rows.
=SUM(OFFSET(H111;5;0;COUNTA(H111:H116) + 1;1))
My idea was to start at H111 and move down 5 rows, use COUNTA to count all non-blank rows and add 1 to adjust for one blank title/colored row in between.
What I want to do is, is to be able to SUM all the accumulated amortizations for every asset in the total amortization cost field and to be able to add new items which the formula dynamically responds to.
Help is very much appreciated. Thank you!
With added tax rate
Maybe:
=SUMIF($A$106:$A$10000,"Accumulated amortization",$H$106:$H$10000)
You may need to adjust the 10000 to reflect the lowest possible row, but the range can be significantly larger than the used range.
One problem with OFFSET is that it is volatile and, depending on the complexity of your entire worksheet, may add significantly to execution times.
Another issue with OFFSET is that, even if you do use it to generate an array of results, it requires further manipulation before you can effectively use those results in formulas.
Morning, I am working to review/analyze a set of lab data. It has up to 95 samples, so I am looking to automate as much as I can, but I am at a wall with this one.
Each sample has three columns; a concentration, a qualifier (which may be blank, u, or j), and a MDL. Currently the data starts in column AC, with 3 columns per sample, but for a variable number of samples. My goal right now is to count the number of samples that have a "u" in the qualifier column AND have an MDL that is not equal to their concentration. (I tried pasting in a table, but I couldn't get it to work so apologies).
I am currently using a simple sum of COUNTIFS statements "=SUM(COUNTIFS(AD5,"U",AC5,"<>"&AE5)+COUNTIFS(AG5,"U",AF5,"<>"&AH5)...", however I have to update the cells referenced manually which is a bit time intensive and can introduce errors. Does anyone know how I might use an offset formula or something? I figure that is my best bet since the data is uniformly setup. I just can't get it right on my end.
Many thanks for any help!
A simple solution is to reformat to a single table (probably using VBA for automation?) then create a fourth column with a logical value for the concentration == MDL test. Then use countifs like you proposed.
This can be obviously extended by creating a fifth column with the AND() test and using simple countif.
If you have samples on different columns (I get the impression because of: =SUM(COUNTIFS(AD5,"U",AC5,"<>"&AE5)+COUNTIFS(AG5,"U",AF5,"<>"&AH5)...",
and you really want to use offset, you can create a "sample count" cell for each table (located at row 1+ the maximum sample size you have in the whole book) and then use offset and countifs like you wrote. References should update automatically when copying.
If I understand correctly, you could use countifs straight up if the references are set up correctly and copy the cell, pasting it at the location I said before
(1+ the maximum sample size you have in the whole book)