Finding average but with a maximum value per cell in excel - excel

I am trying to find the average of a range of cells that fall between a predefined/criteria range (i.e. 0-2) but treating the end of the range (2 - in this example) as the maximum amount to be used in calculating the average over the range of cells in excel.
Here is an example of the data I am interested finding the average for:
COST
2
3
5
7
If finding the average using the range of 0-2, it should be 2, as you'd be treating anything with the cost of 2+ as 2. So, the total is 2+2+2+2=8 and there are 4 cells so the average would be 2.
Another example would find the average using the range of 0-3, the average would be 2.75, as the first value in the above table falls between the criteria range and the rest match or fall outside the high end of of range so they are assigned the maximum of 3. So, the total is 2+3+3+3=11 and there are 4 cells so the average would be 2.75.

You can try:
=SUM(IF(A2:A5>=C2,C2,A2:A5))/COUNT(A2:A5)
in pre-O365 it must be entered as array formula with Ctrl+Shift+Enter

Related

How to calculate average rating in excel with excluding blank cells?

How to calculate average rating in excel with excluding blank cells?
In other way
if cells is empty --> not calculate rating
if 0 or greater than 0 to 5 --> calculate rating
then calculate average ratings.
Do you mean that your range includes values of less than 0 and/or larger than 5 and empty, but you only want to calculate value from 0 to 5?
I think you'd better use pair of SUMIFS and COUNTIFS, with set of your conditions (>=0, <=5, not blank...).
For example, assumed your value range B1:B6:
=SUMIFS(B1:B6,B1:B6,">=0",B1:B6,"<=5")/COUNTIFS(B1:B6,">=0",B1:B6,"<=5")
This give out result of average of 2.5
And please note that COUNTIFS or AVERAGE... they do not count empty cells by default.

Excel - function to find the highest sum in a table using each row and column only once

I've got a table in excel with 10 rows and 10 columns.
The table contains 100 different values between 1 and 3.
I want to find the highest sum of 10 values using only 1 value from each row and 1 from each column.
Do u guys know a function that finds the highest sum? - I've tried to do i manually, but there are to many combinations!
Hope it makes sense.
Thanks in advance:)
My solution builds on what I wrote in the comment, i.e. you first take the maximum value in the 10x10 array, then the maximum in the 9x9 array (excluding the row/column of the first maximum), etc. My solution tries not to do everything in one formula, but I add a few helper columns, and a bit more helper rows (it is fast and dirty, but it works and is easily audited/understandable). You always can do this on a separate worksheet which you could hide if needed.
The screenshot above goes from cell A1 till Y31.
The key formulas:
3.55 is the result of =MAX(B2:K11)
The first gray cell is =IFNA(MATCH($M12;B2:B11;0);""), and you drag this 9 cells to the left. This tries to find a match with the max result in each column of the table;
The 10 left of the 3.55 is =MATCH(TRUE;INDEX(ISNUMBER(P12:Y12);0);0) , and gives the column number of the max value.
The 2 next to the 10 is =INDEX(P12:Y12;N12) and gives the row number of the max value.
The 1 in cell B12 is =IF(OR(B$1=$N12;$A12=$O12);0;1), and creates a 10x10 matrix with a row and column with zeroes where the previous max value was found.
Then you multiply this with the preceding matrix and create a new 10x10 matrix below (enter {=B2:K11*B12:K21} array formula (ctrl+shift+enter) in B22-K31
You then copy/paste rows 12 till 31 9 times below
The 23.02 is the total sum =SUM($M$12:$M$211) from all 10 maximum values and is the result you are looking for. The 10 is just a check with =COUNT($M$12:$M$211)

Excel: Trying to consolidate weighted average data from Sheet1 and summarize to Sheet2 when Sheet 1 has variable number of rows

I can't figure out how to get formula to recognize variable # of rows for each weighted average calculation in a single, replicable formula combination. I've tried (and failed) to use combinations of sumproduct / address / match / offset / countif / if / etc. I feel like this should be super easy, but I'm stumped.
Sheet1 has variable number of rows for each CompanyX/Y/Z
Value Weight
CompanyX DataA DataA1
CompanyX DataB DataB1
CompanyX DataC DataC1
CompanyY DataN DataN1
CompanyZ DataU DataU1
CompanyZ DataV DataV1
But I want to summarize weighted average with at Company level e.g.
Weighted Average
CompanyX ResultABCA1B1C1
CompanyY ResultNN1
CompanyZ ResultUVU1V1
Can't get there from here...help!
I believe you need a pair of SUMPRODUCT calls. The first is to get the product of value and weight for a company. The second is to just get the sum of the weights for a company. The first term in this formula is used to check that the company matches (it returns 0 or 1 with the --); the second and third terms are for the weighted average math.
Array formula (enter with CTRL+SHIFT+ENTER) in cell G3, copied down from there, see picture for other ranges.
=SUMPRODUCT(--(F3=$B$3:$B$8),$C$3:$C$8,$D$3:$D$8)/SUMPRODUCT(--(F3=$B$3:$B$8),$D$3:$D$8)
Ranges and result

PercentileIF Excel (or rangeif)

A B
1 5
2 10
2 15
3 20
I want to calculate percentile for a column of values B if A is equal say 2. That's I want to get range of B2,B3 and calculate percentile of this.
So basically the question is: how do I select range in one column with the checking with another column?
I.e. it works perfectly with SumIf and CountIf, I just need the same with PercentileIf. Thx!
This will give you the 25th percentile of A1:A6 for all cells where the value in B1:B6 equals 2:
=PERCENTILE.INC(IF(B1:B6=2,A1:A6,""),0.25)
It's an array formula and must be entered with Ctrl-Shift-Enter.

Taking the average of bottom n percent in Excel

I have a column of data in excel that I need to take the average of the bottom 10% of. My data reads:
1
2
3
4
5
6
7
8
9
10
so the average of the bottom 30% would be - (1+2+3)/3 = 2. Is there a way to automate this in excel where all I have to do is give it what percent I want and it gives me the answer?
A simpler version: no Array Formula or Indirect required
Assuming data in column A, and required percentage in cell B1 (as a decimal)
=AVERAGEIF(A:A,"<="&SMALL(A:A,COUNT(A:A)*B1))
I'm not entirely sure what you're looking for when you say 'where all I have to do is give it what percent I want and it gives me the answer', but you could perhaps try AVERAGEIF:
=AVERAGEIF(A1:A10,"<="&COUNTA(A1:A10)*0.3)
Assuming that the data is in the range A1:A10. You can have a reference for the 0.3 for the percentage.
=AVERAGEIF(A1:A10,"<="&COUNTA(A1:A10)*B1)
If you put the percentage in B1, then the formula will change accordingly.
Assuming your data is in A1:A10, and your desired % is in B1:
=AVERAGE(SMALL(A1:A10,ROW(INDIRECT("1:"&(B1*COUNT(A1:A10))))))
Note! This is an Array Formula! That means that you have to enter into the formula bar at the top (not in the cell), and press ctrl shift enter when you're done.
This will wrap the formula in these { }, so you'll know you did it right. Typing them in does not work, you have to ctrl+alt+enter!
How does it work?
ROW(INDIRECT("1:"&(B1*COUNT(A1:A10))))
The Count checks how many items you have in your list, so it knows how many numbers it will need to average. Let's say B1 is 40%.
40% of 10 items is 4, but 40% of 20 is 8.
Since it's 10 entries long, we'll creating an "array", a series of numbers from 1 to 4 (40%).
*SMALL(A1:A10*
SMALL finds the *n*th smallest number in a range. With our array of 1 to 4, it will find the lowest 4 entries.
AVERAGE(
Then we average the result :)

Resources