Taking the average of bottom n percent in Excel - 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 :)

Related

Excel Formula to calculate Average rating out of 5

I have a table of data where ratings are given as V good - 3, Good - 2, Avg - 1 but if the value is NA I want to exclude that from Avg.
I do have values stored as Good, V Good, Avg against the record.
Any excel formula for this to calculate rating out of 5.
Thanks in advance.
Please try this formula. It's designed for entry in a cell in row 2 from where it can be copied down.
=IFERROR(SUMPRODUCT((COUNTIF(C2:E2,{"V Good","Good","Avg"})*{3,2,1}))/SUMPRODUCT((COUNTIF(C2:E2,{"V Good","Good","Avg"}))), "NA")
There are only 3 columns in your example. Therefore I don't understand your request for a "rating out of 5". However, you can use the same formula on a larger range, of 5 or more columns. Just change both range references to include more columns, like E2:G2. The important thing is to change both to the same size of range.

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)

How to sum the bottom value of a column that changes size?

So I'm tracking some investments in excel and the columns of interest are the total value of investments, the value for each investment, date. I have a formula for the net total to the side and I'm using this to manually type the net total into the column. I'm also using this data to create graphs of value vs date.
How can I change this formula so it will always just add up the final values for the total of each investments? I dont want to have to manually fudge the formula everytime I update the tables.
I want to do this because the table is a bit busy due to the data needed for the graphs, it'd be nice just to have the net total by the side and highlighted.
net total date 1 2 3
111 13/01/18 100 10 1 Net total: `Sum(c2, d2, e2)`
121 14/01/18 100 20 1
So I want the net total to just sum the bottom values for columns titled 1, 2, 3. I want it to be dynamic so i can then just type in the net total into the correct column and i can update all the graphs. But also want the net total to be on the side for easy viewing too instead of it getting lost in the raw data
there is a trick using "lookup()":
search(999999;A:A) returns value equals to 999999 or last value if 999999 is greater than every values. So your formula will be:
Net total: "lookup(999999999;C:C)+lookup(999999999;D:D)+lookup(999999999;E:E)"
(assuming none of the values is greatrer than 999999999)
Will the final value from each column always be the same row? If so then this formula will sum the last row in columns B, C and D by finding the last number in column B
=SUM(INDEX(B:D,MATCH(99^99,B:B),0))

Excel countif(s) multiples

I'm trying to calculate the count of multiple occurrences of a figure using countif.
I have the range set but I need a calculation which can count in multiples of 50 without me having to type thousands of versions of countif (=COUNTIF(B2:B5,">=50")-COUNTIF(B2:B5,">100" etc.).
Data Count
50 1
70 1
80 1
10 0
150 3
This data should show 6 but at the moment I'm getting 4.
First you can start by making bins. you can make it with Data analysis tool or half manual
Like in the example, on A2 enter 0 and on b2 enter =a2+50
Same goes for a3 enter =b2 and last on a4 =a3+50
Now you can drag it down as much as you like.
Instaed of using countif use sumif finction. let's assume your data is on cloumn H and the values you want to sum are in column I, then on c2 enter
=SUMIFS(I:I,H:H,">"&A2,H:H,"<="&B2)
you can drag it down as much as you like.
Simply use Excels ROUNDDOWN function:
e.g. for B2: =ROUNDDOWN(A2/50,0)

excel averaging every 10 rows

I have a big data set which has about 9000 rows. I have a few variables for every year from 1960 onwards, and I need to average them in ten year bins. So I have something like:
1
2
3
4
2
3
4
5
Now I need to average the first ten rows, then the next ten, and so on, for all 9000-odd rows. I can do that, but then I get all these rows averaged in the middle which I don't need, and I can't go about deleting those many rows. There has to be an easy way to do this, surely?
Would appreciate any help!
Suppose your data starts from A1. Try this one in B1:
=AVERAGE(INDEX(A:A,1+10*(ROW()-ROW($B$1))):INDEX(A:A,10*(ROW()-ROW($B$1)+1)))
and drag it down.
in B1 it would be =AVERAGE(A1:A10)
in B2 it would be =AVERAGE(A11:A20)
in B3 it would be =AVERAGE(A21:A30)
and so on.
General case
If your data starts from An (where n is 2,3,4,...), use this one:
=AVERAGE(INDEX(A:A,n+10*(ROW()-ROW($B$1))):INDEX(A:A,n-1+10*(ROW()-ROW($B$1)+1))
where you should change n to 2,3,4,...

Resources