Conditional median in MS Excel

前端 未结 4 673
深忆病人
深忆病人 2021-01-04 06:26

I\'m trying to calculate the conditional median of a chart that looks like this:

A  |  B
-------
x  |  1
x  |  1
x  |  3
x  |  
y  |  4
z  |  5
4条回答
  •  南笙
    南笙 (楼主)
    2021-01-04 07:16

    Nested if statements.

    =MEDIAN(IF(A:A = "x",IF(B:B<>"",B:B, ""),"")
    

    Not much to explain - it checks if A is x. If it is, it checks if B is non-blank. Anything that matches both conditions gets calculated as part of the median.

    Given the following data set:

    A | B
    ------
    x | 
    x |     
    x | 2
    x | 3
    x | 4
    x | 5
    

    The above formula returns 3.5, which is what I believe you wanted.

提交回复
热议问题