PercentileIF Excel (or rangeif) - excel

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.

Related

Excel formula: make the average depending on a cell

I want to make a formula that turns in a VBA code that makes the average for column A even though there are some 0 there. I want to divide it by a the number in a cell that counts the objects in column A.
I used to use this formula, but it divides my sum incorrectly because I have 0's (I want to keep the 0's there):
=AVERAGE(Sheet1!$B$2:$B$10000)
The easiest way to do this, is to get the total of column B by using sum(B:B) (or a more specific range, if you want), and the amount of non-blank cells in column A by using counta(A:A) (in my comment I used count which only counts the amount of numbers in the range, counta should count all non-blank cells). You can then divide the former by the latter to get the number you are looking for, resulting in a formula looking something like
=SUM(B:B)/COUNTA(A:A)
If you already have the count of column A in a cell (e.g. E3), it's even simpler, just use something like
=SUM(B:B)/E3
You can use AverageIf for such a purpose, as you can see in my example:
Row/Column A B C D
1
2 2 =AVERAGE(B2:B5) => value 3
3 4 =AVERAGEIF(B2:B5;"<>0") => value 4
4 0
5 6

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 do I make a cell value represent a number in Excel?

I have
Year 1 2 3 4 5 6
I'm trying to make it so that each year number 1-6 is equal to another number value i.e. Year 1 is equal to 5. Year 2 is equal to 6.
You will not be able to store one value in a cell and use a different value for calculation. However you may do this calculation with the help of a lookup from another table,
Assuming you have the years in Column A and the corresponding mappings are in Column E and F, you can use the below formula in Column B,
=INDEX(E:F,MATCH(A1,E:E,0),2) * 2
This formula lookups the value in A1 in the table E:F and returns the corresponding Column F element. That is finally multiplied with the 2 to show your result. Instead of just using just A1 for multiplying by 2, you should be using INDEX(E:F,MATCH(A1,E:E,0),2). Hope this helps.

Formula returning Column A value for row containing MAX value of a range

Assume I have the following table:
A B C
1 Week 1 Week 2
2 Melissa 114.7 82.8
3 Mike 105.5 122.5
4 Andrew 102.3 87.5
5 Rich 105.3 65.2
The names are in column A, the Week values are in Row 1. (So A1 is blank, B1 = Week 1, and A2 = Melissa.)
I'm trying to build a formula that looks at all the values in a known range (in this example, B2:C5), chooses the highest value of the bunch (here, 122.5) and returns the name of the person from Column A that got that value. If I use this formula, it works for the values in range B2:B5:
=INDEX(A2:A5,MATCH(MAX(B2:B5),B2:B5,0))
That returns Melissa but if I expand the range to include more than just column B's values, I get an #N/A returned:
=INDEX(A2:A5,MATCH(MAX(B2:C5),B2:C5,0))
The weird part (to my simple brain) is that the MATCH portion of the formula works fine, if I just put in this formula, it returns the highest value of 122.5 from C3:
=MAX(B2:C5,B2:C5,0)
So clearly something it going wrong when I'm using either the MATCH or INDEX commands.
Hopefully this makes sense and someone can point out my error?
Try this:
=INDEX(A:A,MAX((B2:C5=MAX(B2:C5))*ROW(B2:C5)))
This is an array formula and must be confirmed with Ctrl+Shift+Enter.
Note: Match can only search one vector at a time. It can be one row or one column or one array. It cannot be two or more rows or columns or a 2D array.
Do it "twice"? Please try:
=INDEX(A2:A5,IFERROR(MATCH(MAX(B2:C5),B2:B5,0),MATCH(MAX(B2:C5),C2:C5,0)))
If you are going to have up to 52/53 weeks to cope with I'd suggest instead inserting a helper column with the MAX for each row. Make that an new (inserted) ColumnA (say =MAX(C2:BC2) etc.) and a simple VLOOKUP should serve, say:
=VLOOKUP(MAX(A:A),A:B,2,0)

Keep excel offset within worksheet

I have a table like this:
Length 4
year 1 2 3 4 5
A 100 400 300 200 400
B
And in column B I want a sum of A from the past [length] years. For this I figured I needed an OFFSET, so my function is (for year 2):
=SUM.IF(OFFSET(B3;0;0;1;-B1);">0")
The if statement is used so it doesn't give an error when it reaches the edge of the table, but for years 2 and 3 the OFFSET range is outside of the worksheet so it doesn't work. How can I specify a condition that it just doesn't sum anything that isn't on the worksheet?
In A2:
=SUM(INDEX(1:1,COLUMNS($A:A)):INDEX(1:1,MAX(1,COLUMNS($A:A)-3)))
Copy to the right as required.
Regards
Ok, it was hard to decypher the question:
When you ask column B, I guess you mean row 4, right?
You don't need SUMIF, because SUM doesn't count empty cells or cells
with non-numeric value.
The reference to the length value should be absolute, so it doesn't
change as you copy the formula:
$B$1
OFFSET's Width value cannot be negative, rather have the Cols value =
-[Length]:
OFFSET(C3;0; -$B$1...
(Now you are referencing 4 columns left to C3)
Make sure it is not out of the worksheet by not letting more than the [column number of the given cell minus 1] be referenced left from the cell:
OFFSET(C3;0; -MIN(COLUMN(C3)-1;$B$1)...
That is the starting point of your range to sum; you should sum it
up to recent year's value. So the correct formula in C4 is:
=SUM(OFFSET(C3;0;-MIN(COLUMN(C3)-1;$B$1)):C3)

Resources