I'm looking to calculate the average of a series of cells across multiple tables on the same spreadsheet.
Each manager has a table and in each table, there are a number of statistics e.g. Total Activity, Outbound Calls & Credit. Each table is situated one under the other e.g. Danny's table might be situated on rows 1- 5, Ann's 7-12, Katie's 14-19. I need to find the average for each statistic and output it to my summary page.
I've tried using Application.WorksheetFunction.Average but could not get it working as the range is scattered among various rows. I do however know that each variable appears in every 6th row so I tried For i = 2 To lastRow Step 6 which outputted the values into cells and calculated the averages based on that cell range but I'd rather have something more direct if possible.
Could anyone offer a valid solution to this?
Sample of data beneath. looking to get the average for each of the 4 variables.
Alternative 1
If there are other values than the values you want an average of in column B, you can use SUMPRODUCT.
Enter this formula in any cell in any other column than column B. It will calculate an average of every 6th value starting on row 2.
=SUMPRODUCT(B:B*1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2))/SUMPRODUCT(1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2))
B:B Array of all values in column.
1*NOT(ISBLANK(B:B)) Array of 1 or 0, 1 on non blank cells in column B, 0 for blank cells.
1*(MOD(ROW(B:B),6)=2) Array of 1 or 0, 1 on row 2, 8, 14 and so fourth
SUMPRODUCT(B:B*1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2)) sums all non blank cells in column B on every 6th cell starting at row 2.
SUMPRODUCT(1*NOT(ISBLANK(B:B))*(MOD(ROW(B:B),6)=2)) counts all non blank cells in column B on every 6th cell starting at row 2.
To speed up the formula you can replace B:B with for example B1:B100 depending of the number of rows that have values.
Alternative 2
If there are nothing but values you want an average of, then you can use SUBTOTAL as suggested by Dominique. =SUBTOTAL(1,B:B)
Related
Link to data screenshot: https://imgur.com/a/CrRLb6d
I am working with an excel file that has a recurring group of 4 columns (see image: column headers are Time, Med1, Med2, Med3). On the left, in column B, I want to have the sum of the values on a row, but the only values that should be summed are those that meet the criteria:
The value is in a Med1 column (all columns that have the Med1 header), and;
The adjacent Time value on the same row (1 column to the left of a Med1 column) is 1.5 or greater.
So, for example looking at row 10 (highlighted in the example), the Med1 values in E10 and I10 should be summed in B10 (because their respective Time values in D10 and H10 are 1.75 and 1.5, respectively, i.e. >=1.5), but not the Med1 value in M10 (Time value in L10 is 1.25 which does not meet the second criterion above).
Some additional info:
Each of these ‘blocks’ has a fixed width of 4 columns, without gaps in between (in the actual excel file, there are 240 of these blocks).
The pattern of Time continues like in the example shown, always starts at 0, one row lower compared to the previous block.
What I have tried: SUMIF, SUMIFS and INDEX functions, but I get #VALUE errors if I try to combine criteria (especially as it is not 1 Time column value that needs to be checked for a row, but multiple Time column values across a row).
Previously, I just wanted to sum all Med1 value on a row (regardless of the adjacent Time value), like this:
=SUMIF($D$2:$O$2;"Med1";D3:O3)
However, with the second criterion of the adjacent Time value, I cannot seem to get it to work. Any help is appreciated!
If the blocks are all right next to each as shown in your image, and the value you want to sum is always 1 cell to the right of the time value, and only the time values can be >= 1.5 (all of your MedX values are < 1), then this formula would work for you:
=SUMIF(D3:O3,">=1.5",E3:P3)
If it's possible for the MedX values to be >= 1.5, then this more explicit formula should work for you:
=SUMPRODUCT(--($D$2:$O$2="Time"),--(D3:O3>=1.5),--($E$2:$P$2="Med1"),E3:P3)
I want to find the average values of difference of two consective rows (like C2-c1). Also i want to repeat this operation after every fifth column. Technically
repeat for every fifth column( average (succeeding row- preceeding row)). average value should be represented in another row or column.
In column D use the formula,
=IF(MOD(ROW(),5)=0,C2-C1,"")
This would give the difference for every 5th row. Then use the below formula to find average,
=AVERAGE(D:D)
Note:- since the formula contains ROW() function, you have to start from row 1 for the formula to work. If not alter the formula accordingly
thank you for taking the time to look at this question.
I'm looking for an equation that can easily take the numerical values from Sheet 1 (the first picture) which has 2 blank cells in between values for four values and then has 4 blank cells and then the other four values. I'm not sure if I am making sense but hopefully the picture I have attached helps.
Notice 2 blank rows between first 4 rows with values (Rows 2-11) and same between rows 16 and 25.
Also notice the 4 blank rows between the two sets of values.
For me, this is repeated for 700 values, same set up of 2 blank rows for 4 sets of values and then 4 blank rows and then four sets of values with 2 blank rows. I'm sure there is an easier way to do this.
I'm trying to recreate Sheet 2 from Sheet 1 using an equation. Is this possible?
Apologies in advance, English isn't my first language.
If the numbers are going to start in B2 and the intervals and offset staggers are static then,
=INDEX(B:B, 2+(ROW(1:1)-1)*3+INT((ROW(1:1)-1)/4)*2)
If the first number is in S6 then,
=INDEX(S:S, 6+(ROW(1:1)-1)*3+INT((ROW(1:1)-1)/4)*2)
Put this in D2:
=IFERROR(INDEX(Sheet1!B:B,AGGREGATE(15,6,ROW(Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A)))/(Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A))<>""),ROW(1:1))),"")
And copy down till you get blanks.
This will return the numbers in order that they appear on sheet 1.
The Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A)) set the data set bounds. This being an array type formula it needs to reference the smallest possible data set. This part finds the last cell in Column A and sets that as the extent of the data set so we do not do unnecessary iterations.
The MATCH part will return the last row that has text in it, if Column A has numbers then we need to change the "ZZZ" to 1E+99 to get the last row in column A with a number.
The AGGREGATE is working like a small in that it will create an array of row numbers and Errors. It will return ROW Numbers where (Sheet1!$B$2:INDEX(Sheet1!B:B,MATCH("ZZZ",Sheet1!A:A))<>"") return true. And an Error where it returns FALSE.
The second criterion 6 in Aggregate tells it to ignore the errors, so it is only looking at the returned row numbers.
The ROW(1:1) is a counter. As the formula is dragged down it will iterate to 2 then 3 and so on. This tells the Aggregate that you want the 1st then the 2nd then the 3rd and so on.
The chosen row number is then passed to the INDEX and the correct value is returned.
If your numbers are in order (smallest to largest like your example) or you want the output in order(smallest to largest) then you can use this simple equation in D2:
=IFERROR(SMALL(Sheet1!B:B,ROW(1:1)),"")
Then copy down till you get blanks.
Here is another formula you might use.
=INDIRECT(ADDRESS((INT((ROW()-ROW($A$2))/4)*14+ROW(A$2))+(MOD(ROW()-ROW($A$2),4)*3),COLUMN($A$2),1,1,"Sheet1"))
You can paste it to the first cell where you want the result and copy down.
Note that $A$2 is the cell from where all the counting starts. If your data start from A3 you can change the references accordingly. Note further that ROW($A$2) is long for 2. I chose this syntax to enable you to identify the meaning.
COLUMN($A$2), on the other hand, just identifies Column A as the source of the data to be lifted. Row 2 in this formula is insignificant. It's the A that counts. However, COLUMN($A$2) is long for just 1, meaning column No. 1, meaning A. Once you get your bearing in the formula you can replace COLUMN($A$2) with 1.
I have a design software which extracts data in to an Excel sheet format
The output is divided into 2 columns, each of these columns has more than 1000 rows.
To make use of this data I need to summarize it to a maximum of the 5 highest values from both of the 2 columns. Therefore, this doesn't mean that it's the maximum of one column and its corresponding value, but it may mean that the 2nd largest value of column 1 & the 4th largest value of column 2.
For example ( if we quoted some of the output data):
The values i should pick here are:
If there is any possible way to achieve that, it will be great
Thanks ..
example file: http://goo.gl/UIEFEv
example file 2: http://goo.gl/VSvuVf
Here's a formula solution. I used 20 rows and extracted the rows which contain the top 5 for each column - you can extend to as many rows as required.
With data in A1:B20 use this formula in D1 confirmed with CTRL+SHIFT+ENTER and copied across to E1 and down both columns:
=IFERROR(INDEX(A$1:A$20,SMALL(IF(($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5)),ROW(A$1:A$20)-ROW(A$1)+1),ROWS(D$1:D1))),"")
Note: there are only eight rows extracted because some of the rows contain values in the top 5 for both columns. I added the highlighting in colums A and B to more clearly illustrate
see screenshot below
Edit:
From the comments below it seems that you want a combination of rows which contain the highest value for that column....and rows which contain the highest total for both columns.
In the original formula there are two conditions joined with "+", i.e.
($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5)
The "+" gives you an "OR" type functionality, e.g. in this case rows are included if individual values are in the top 5 in that particular column. You can add other conditions, so if you want to also add any rows which are in the top 5 considering the total of both columns then you can add another "clause", i.e.
($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5)+($A$1:$A$20+$B$1:$B$20>=LARGE($A$1:$A$20+$B$1:$B$20,5))
....and including that in the complete formula you get this version:
=IFERROR(INDEX(A$1:A$20,SMALL(IF(($A$1:$A$20>=LARGE($A$1:$A$20,5))+($B$1:$B$20>=LARGE($B$1:$B$20,5))+($A$1:$A$20+$B$1:$B$20>=LARGE($A$1:$A$20+$B$1:$B$20,5)),ROW(A$1:A$20)-ROW(A$1)+1),ROWS(D$1:D1))),"")
You could refine that further by using combinations of + and * (for AND), e.g. for the new condition you might only want to include rows with a total in the top 5 if one of the single values is in the top 10 for that column...
Explanation:
The above part shows how you can use + for the OR conditions. In the formula if those conditions are TRUE then the IF function returns the "relative row number" of the range (using ROW(A$1:A$20)-ROW(A$1)+1).
SMALL function then extracts the kth smallest value, k being defined by ROWS(D$1:D1) which starts at 1 in D1 (or E1) and increments by 1 each row.
INDEX function then takes the actual value from that row.
When you run out of qualifying rows SMALL function will return a #NUM! error which IFERROR here converts to a blank
The question is a little unclear but if what you mean is to get the 5 highest values of Column A and their corresponding values in Column B then the five highest values in Column B and the corresponding values in Column A then the (non automated) solution is pretty simple.
Click on a cell with a header title in it.
Click on 'Data' in the top menu.
Click on 'Filter' in the 'Sort & Filter' section.
Click on the button on Column A - select 'Sort Largest to Smallest'
Grab the top five values from both columns then click on the button in column B and repeat.
I want to count how many rows have the sum value no greater than X.
Same as this Sum until certain point - MySql but just with an excel formula and only the row count.
Using the same examples as in the above, first limit should give the value 2 and the second 4.
It's easy to do by adding an extra column. In that column you would keep a running total by filling down the a formula like this
Imagining your data has a header row in row 1 and is in A1 to C6 put this in D2 and fill down
=SUM($C$2:C2)
Then in E2 put this
=COUNTIF(D2:D6,"<500")
Changing the number 500 will give you a different limit.