Suppose I have the following data in exce l:
For each row, I want to know what the average range between each unique pair of variables is.
Is there a way to do this in one go, without having to manually calculate the range between every number pair?
Taking row one as an example, the unique pairs and their ranges are as follows:
8 - 5 = 3
8 - 6 = 2
6 - 5 = 1
The average range is (3 + 2 + 1)/3 = 2.
So, the output should be 2, but I want to know if there is a way to do this all in one formula
Paste the following array formula into cell D1 and drag down as far as necessary:
= SUM(ABS(A1:C1-TRANSPOSE(A1:C1)))/(COLUMNS(A1:C1)*(COLUMNS(A1:C1)-1))
(Obviously, you'll have to change the formula above to whatever your cell ranges are.)
Note this is an array formula, so you must press Ctrl+Shift+Enter on the keyboard when entering this formula rather than just Enter.
See below for a demonstration that this formula works.
As in the example in your question, the result for the first row is 2.
Second row:
10 - 1 = 9
3 - 1 = 2
10 - 3 = 7
(9+2+7)/3 = 18/3 = 6
Also note, this formula works for variable column ranges. (It doesn't just have to be 3 columns.) See below for an example with 4 columns. (The formula is in cell E1 and is evaluating over cell range A1:D1.)
8 - 2 = 6
13 - 2 = 11
11 - 2 = 9
13 - 8 = 5
11 - 8 = 3
13 - 11 = 2
(6+11+9+5+3+2)/6 = 36/6 = 6
Related
I have a table with many values as such (this is an oversimplified example):
IDx
Namex
Pricex
1
a
5
2
b
2
1
a2
5
3
c
3
2
b2
9
and another table with only the ID, in which I'd like to add a column that shows the addition of all the values that match that ID, in this example:
IDy
Totaly
1
10
2
11
3
3
I'm guessing this is a combination of vlookup with sum or sumif, I've tried so far:
=SUM(VLOOKUP(IDy1,$IDx$1:$IDx$5,$Pricex$1:$Pricex$5),// don't know how to proceed here
Try this:
B5:B9 = IDx
B16,D5 = Price
=SUMIF(B$5:B$9,B16,D$5:D$9)
I wonder if there's a quick solution to the following:
My goal is to divide a cell value by three, using the same value for three cells in a row, then switch to the next value in the series for another three cells in a row, and so on.
So my starting data would look like:
A B C D E
1 9 12 6 21 27
2 30 9 3 0 3
3 ...
I want the new cells to look like:
AA AB AC AD AE ...
1 3 3 3 4 4
2 10 10 10 3 3
...
Where the cell AA1 = A1/3, AB1 = A1/3, AC1 = A1/3, but AD1 = B1/3 and so on.
I need to do this for many observations, preferably using an excel formula.
Does anyone have any ideas on quick solutions?
Really appreciate your help.
Best,
Henry
Use INDEX:
=INDEX(1:1,0,ROUNDUP(COLUMN(A1)/3,0))/3
Is there a way for excel formulas to look up multiple values in an 2d matrix for excel? For example:
sum(vlookup({2015,2016},Matrix,{2,4,6},False)) = 3 + 4 + 5 + 2 + 3 + 2
2014 1 3 7 11 9 2
2015 3 6 4 12 5 8
2016 2 1 3 99 2 6
I don't necessarily have to use the function vlookup but I prefer not having to use the same function multiple times then summing them since the list {2015,2016} could be quite long.
Put your search criteria in one cell each:
Then use this formula:
=SUMPRODUCT(ISNUMBER(SEARCH($A$1:$A$3,J1))*ISNUMBER(SEARCH(COLUMN($B$1:$G$3),K1))*$B$1:$G$3)
If you want to hard code the numbers then you can do it this way:
=SUMPRODUCT(ISNUMBER(SEARCH($A$1:$A$3,"2015,2016"))*ISNUMBER(SEARCH(COLUMN($B$1:$G$3),"2,4,6"))*$B$1:$G$3)
I like #ScottCraner's answer a lot, I just did it slightly differently, but using close-on the same tricks.
For me, I put the year values in as follows in column N:
N1 = 2015
N2 = 2016
And the columns I wanted to use for the look-up in column O:
O1 = 2
O2 = 4
O3 = 6
Then, I used the following (entered as an array formula - meaning you press CTRL+SHIFT+ENTER after putting it in):
=SUMPRODUCT(ISNUMBER(MATCH(A1:A3,$N$1:$N$2,0))*ISNUMBER(MATCH(COLUMN(A1:G3)-COLUMN(A1)+1,$O$1:$O$3,0))*A1:G3)
Again, Scott's answer is perfectly right, I just added in a different way to get to the same result.
Hope it helps you or someone else facing the same kind of challenge.
I'm looking for a way to find the first specific value above a certain cell.
Using the example below, in the result column every time I hit a A in COL2, I need to substract the value in COL1 to the first A value above.
The trouble seems finding a way to keep the range dynamic...
I thought of =IF(B5="A";A5-INDIRECT("A"&MATCH("A";B:B;0));"")
But of course that only works for the first one as Match will always pick up the first one.
Any ideas? Thanks!
Example :
COL1 COL2 Result
1 A
2 0
3 0
4 A 4 - 1 = 3
5 0
6 A 6 - 4 = 2
7 0
8 0
9 0
10 A 10 - 6 = 4
Try this:
=IF(AND(ROW(B2)<>2,B2="A"),A2-INDEX($A$1:$A1,AGGREGATE(14,6,ROW($1:1)/($B$1:$B1="A"),1)),"")
The AGGREGATE() Function was introduced in 2010.
In D2 enter =IF(B2="A",A2-INDIRECT("A"&MATCH("A"&(E2-1),F:F,0)),"")
In E2 enter =IF(B2="a",COUNTIFS($B$2:B2,"a"),"")
In F2 enter =B2&E2
Copy formulas from D, E and F down all your rows
Column D is the result you're looking for
Am new to Excel, please help me with this:
A B
2 9 =IF(A2:A6>=7,"1","0")
3 4
4 7
5 4
6 5
For B2 the formula works perfectly fine but in B3 it selects from A3:A6.
I know the concept of Absolute referencing. But here in this example it should basically work without any errors, right?
A B c
2 9 1 =Sum(A2:B2)
3 4 2
4 7 33
5 4 3
6 5 22
The above example works fine. What is the difference between two?
If you want the A2:A6 range to float down as you copy the formula to other rows, use:
=IF(MAX(A2:A6)>=7, 1, 0)
However, if you want row 6 locked as the finite terminator of the range then lock it as absolute with a $ like this,
=IF(MAX(A2:A$6)>=7, 1, 0)