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.
Related
I have an excel sheet in CSV that has 8 columns A-H and thousands of rows with values 0 or 1 depending on truth value.
I'm looking for the Excel function in which I can select rows where column A and B are true so that I can check another columns probability given A&B. IE P((A&B)|D) (where | means given).
I'm really new to excel and having difficulties finding how to only select rows that meet this criteria.
The following formula entered in I1 will return a 1 if both A1 and B1 are true.
=IF(AND($A1=1,$B1=1),1,0)
Copy it down or autofill to identify all rows where A and B are true.
The $ sign before A and B make the column references absolute meaning if you drag the formula to the right, the references to columns A and B will remain.
Because Excel implicitly interprets 0 = FALSE and 1 (or any other number) = TRUE the formula could be shortened to:
=IF(AND($A1,$B1),1,0)
The probability of C being 1 given that A and B are 1 can be calculated by counting all rows where A, B and C are all 1 and dividing by the number of rows where both A and B are 1:
=COUNTIFS($A:$A,"1",$B:$B,"1",C:C,"1")/COUNTIFS($A:$A,"1",$B:$B,"1")
Again, references to A and B are absolute, while C is relative so you can drag right to get probabilities for columns D to H.
COUNTIFS only counts the rows where all of the criteria are met and allows you to specify up to 127 range/criteria pairs.
EDIT
You could also use:
=AVERAGEIFS(C:C,$A:$A,1,$B:$B,1)
to get the probability.
The Excel File is like this
A B
1 0
0 1
1 1
0 1
0 0
1 0
I want to use Countifs function to count how many rows have at least one "1" in any columns, like
=Countifs(A:A+B:B,">=1")
or
=Countifs(or(A:A=1,B:B=1))
I know I can add a Column C, let Column C = Column A + B, and then just count Column C; or I can count the total rows and count rows with "0" in both columns, and then calculate Total Row - Both "0". But in real Scenario, I have more complicated situation, so I prefer not using these two solutions.
Use a SUMPRODUCT function to provide cyclic calculation.
=SUMPRODUCT(--((A1:A6)+(B1:B6)>=1))
SUMPRODUCT does not like trying to calculate text values and full column references slow it down so keep your ranges to a minimum. Using the INDEX function can help isolate a dynamic range of true numbers.
Another solution using array formula:
=SUM(IF(A1:A6=1,1,IF(B1:B6=1,1,0)))
Being an array formula, you'll have to enter this formula by pressing Ctrl+Shift+Enter together.
Use =COUNT(A:A)-COUNTIFS(A:A,0,B:B,0) to count both 0 columns and subtract it from the total rows:
Or you can use:
=COUNTIFS(A:A,1,B:B,1)+COUNTIFS(A:A,0,B:B,1)+COUNTIFS(A:A,1,B:B,0)
if it is not clear what it the total number of rows.
I have 4 different IF(AND) statements in 4 different consecutive columns. I need to return the calculated values from each of these cells in a separate column.
Column J has the formula:
=IF(AND($D4
Column K has:
=IF(AND($D4>=$G4, $D4<=$H4),0.5*3.33,"-")
Column L has:
=IF(AND($D4>=$H4, $D4<=$I4),0.75*3.33,"-")
Column M has:
=IF(AND($D4>=$I4),3.33,"-")
My goal is to have the 5th Column (N) calculate the total of Columns J through M when they have a value and not a "-".
If I understand you correctly, I suspect that the following will achieve what you are trying to achieve:
=SUMIF(J1:M1,"<>-")
Essentially, this takes the range of the data you are looking at and adds it up where it is not equal to your marker of a non-value, "-".
Hope this helps.
Cheers!
I have 2 columns looking like this:
Column 1 Column 2
1 x
x 2
2 2
x x
1 2
I want to do two things;
For each row match (row n column 1 = row n column 2) it should mark cell n in column 1 green if there is a match and red if it is not.
It should create a sum cell where each match is worth 1 point, in this case column 1 should result in 2 points.
Is this even possible with excel and if so, how is it done?
For the first part of your question:
It should mark cell n in column 1 green if there is a match and red if it is not
You can do this using Conditional Formatting.
Ex:
Assume column A and column B, with the values starting in row 2.
The following conditional formatting would highlight column A values in green if they match the corresponding value in column B in the same row, otherwise red.
Highlight the values in column A, then apply this conditional formatting.
For the second part of your question
It should create a sum cell where each match is worth 1 point, in this case column 1 should result in 2 points
The following array formula will tally all the matches and show you how many there are:
=SUM(IF(A2:A6=B2:B6,1,0))
Assuming again that we are in columns A & B with your sample data.
Remember to commit this formula using Ctrl+Shift+Enter.
Per comment from andy holaday, here is another formula that will work:
=SUMPRODUCT(N(A2:A6=B2:B6))
or
=SUMPRODUCT(--(A2:A6=B2:B6))
These are not CSE formulas so you would not need Ctrl+Shift+Enter to commit them.
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)}