How can I find the median of the difference of two rows? - excel

I have two rows in two different sheets in Excel. Each row has 20 elements. I need to find the median of the difference of the corresponding elements in these two rows. I want this output to be in just one cell. I don't want to add another row in my result.
I have:
If Row1 = p1 p2 p3.... p20
If Row2 = q1 q2 q3.... q20
I need:
result cell = Median of ((p1 - q1), (p2-q2)....(p20-q20))

{=MEDIAN(P1:P20-Q1:Q20)}
This is an array formula you have to validate with Ctrl + Shift + Enter
[EDIT] Including brettdj's suggestion from the comments below, you can try this formula too:
{=MEDIAN(Sheet2!A2:T2-Sheet1!A1:T1)}

Related

Formula to Return Text in the Row of Largest Number

Column A Has Text & Columns B, C & D contain numbers.
For Ex.)
A... …B C D
John 4 6 2
Dave 4 6 4
Mike 4 5 1
Bill 2 5 9
I would like a cell to return the name in column A that has the Largest Number in Column B. And if there are similar numbers, go to the next column and determine which is highest, and if that is tied go to the next column and so on.
Any help would be appreciated.
We can de-conflict ties.In E1 enter:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))
and copy down. Then in another cell enter:
=INDEX(A:A,MATCH(MAX(E:E),E:E,0))
EDIT#1
This is only good for 3 columns of numbers, but it is very easy to add additional de-confliction terms if necessary:
=B1 + C1/(10*MAX(C:C))+D1/(100*MAX(D:D))+E1/(1000*MAX(E:E))
For an expandable number of rows/columns, use a helper row with the same number of columns as number columns in your data. The formulas below reference the following image (the data are in A1:G7):
B9-->=MAX(B1:B7)
C9 (fill over the remaining columns to G9)-->
=MAX(IF(MMULT(--($B1:B7=$B9:B9),--(ROW(INDIRECT("1:"&COLUMNS($B9:B9)))>0))=COLUMNS($B9:B9),C1:C7))
The following formula will give the answer (shown in A9 above):
=INDEX(A1:A7,MATCH(TRUE,(MMULT(--($B1:G7=$B9:G9),--(ROW(INDIRECT("1:"&COLUMNS($B9:G9)))>0))=COLUMNS($B9:G9)),0))
UPDATE WITH ALTERNATIVE METHOD
Using a helper column instead, again referencing the image below (the data are in A1:G7):
I1 (fill down to I7)-->
=SUM(--(MMULT(SIGN(B1:G1-$B$1:$G$7)*2^(COLUMN(G1)-COLUMN(A1:F1)),--(ROW(INDIRECT("1:"&COLUMNS(B1:G1)))>0))>0))
The following formula will give the answer (shown in J1 above):
=INDEX(A1:A7,MATCH(MAX(I1:I7),I1:I7,))
As a bonus, notice that the helper column corresponds to the order that you would get from sorting the data by each column left-to-right. In other words, you could use the helper column to perform a formula-based multi-column sort on strictly numeric data. For the last image, entering the following array formula into a range with the same dimensions as A1:G7 gives a descending sort on columns B through G:
=IF(A1:A7=A1:A7,INDEX(A1:G7,MATCH(ROW(A7)-ROW(A1:A7),I1:I7,0),))

Conditional Formula for excel

I am trying to do addition/subtraction from a total of one column, based on the value of a different column.
Here are the details:
Column H2:H61 has 3 possible values: Complete, Incomplete, Does Not exist.
Column I2:I61 are integers.
What I'm trying to accomplish is, for each Row in column H, evaluate if the value is "Complete". If it is, then, in a running total cell, convert the corresponding Row in I to a negative number and add it to the total. If it isn't, leave the number a positive number and add it to the total.
Example:
H2 = "Complete" I2 = 1.5
h3 = "Incomplete" I3 = 0.5
h4 = "Complete" I4 = 2.0
The total is 3
EDIT
Here is the full scope of it:
Excel Screenshot
So, the total values of I and L is currently 40.
What I'm trying to do is, for example, if H2 = "Complete", then I want to subtract I2 (which is 1.5), which would change the total value to 38.5.
H3 is "Does Not Exist" and != "Complete", so the total would still be 38.5.
H4 is "Complete", so the total would be 37.5
so on and so forth. Hope this helps clarify for everyone!
Try following formula in K2 cell then drag and down.
=SUMIF($H$2:$H2,"Complete",$I$2:$I2)-SUMIF($H$2:$H2,"Incomplete",$I$2:$I2)
I guess you want something like:
=40-SUMIF(H:H,"Completed",I:I)
assuming you do not have the 40 total in either Column H or I.
I figured it out.
What I did was in a separate cell I made the following formula:
=SUMIF(H2:H61,"Completed",I2:I61)
From there, I used that cell to create the following formula to get the result I wanted:
=P31 - (S30+S31)
The S30 and S31 cells are there because I was counting for each "completed" value in two separate columns.

How to get weighted sum depending on multipliers in column in Excel?

I have the table in Excel:
In column C (Sum) I want to get sum this way:
If in column A or B value is 1 then take Amount 48 and multiply by Multiplier (1) = 2.
If in column A or B value is 0 then take Amount 48 and multiply by Multiplier (0) = 1,5.
Then K1 and K2 summed.
So for row 2 the result in column C will be: 48*2 + 48*2 = 192.
For row 5 the result in column C will be: 48*1,5 + 48*2 = 168.
Is it possible to automate this process using Excel formula for C column (inspite of number of columns)?
Or you could use Countif (no shorter though)
=COUNTIF(A2:D2,0)*I$2*I$1+COUNTIF(A2:D2,1)*I$3*I$1
Use Ctrl+Alt+Enter when entering (since it's an array formula)
EDIT: I'm not great with formulas, so there is I'm sure a shorter alernative...

Sum the values of if statements on multiple rows? (Excel)

Say I have a spreadsheet which looks like this:
A B C
1 In Actual Predicted
2 Thing One 300
3 Thing Two 564
4 Thing Three 256 1065
I want to be able to get a sum of the "predicted" column which incorporates values from the "actual" column if the "predicted" value is empty.
I.e. in this case, the value would be 300 + 564 + 1065 = 1929.
I know that I can achieve this for any individual row like so:
IF(C2="",B2,C2)
How do I get a sum of these "if" statements for each individual row?
Thanks.
That can be done with Sumifs() and no helper columns
=SUMIFS(B:B,C:C,"")+SUM(C:C)
Cell D2 = IF(C2="",B2,C2)
Cell D3 = IF(C3="",B3,C3)
...drag / copy to all relevant D cells...
Cell E1 = Sum(D:D)

Excel, Get count if two cells have specifice value

i have an excel sheet with some test result(PPV Predictive Positive Value) like below, i want to find out the count if
Test1=1 Test2=1 count is 2
Test1=1 Test2=0 count is 1
Test1=0 Test2=1 count is 1
Test1=0 Test2=0 count is 1
Let's assume your table starts in A1 cell. Write this in C2 cell:
=MAX(A2+B2,1)
Or if you are a Boolean maniac:
=AND(A2;B2)+1
Then count the sum at the bottom of the column.
If Test1 is in col A and Test2 is in col B, you could use a countifs formula like =countifs(A:A,1,B:B,1) for your first condition. Then, =countifs(A:A,1,B:B,0), =countifs(A:A,0,B:B,1), and =countifs(A:A,0,B:B,0) for your others.
The formula works by looking in col A for the condition you specify(1 or 0) and doing the same for col B, then only counting the ones that meet both criteria.

Resources