I want to determine a MEDIAN of values in one column based on meeting conditions in *two* other columns. I'm using MS Excel.

I know I have to process the MEDIAN function as an ARRAY (ctrl + shft + enter) using an IF function, and this works fine if I only use 1 condition within my IF statement. However, as soon as I try to incorporate *2* conditions using the AND function, I get a median of 0 (i.e., it doesn't work).

**How do I calculate a median of values in one column based on matching conditions of more than one other column?**

*Example*:

Let's say I want to find the median of values in C when A = 1 and B = x:

```
A B C
1 x 10
1 x 20
1 y 30
1 y 40
2 x 10
2 x 20
2 y 30
2 y 40
3 x 10
3 x 20
3 y 30
3 y 40
4 x 10
4 x 20
4 y 30
4 y 40
5 x 10
5 x 20
5 y 30
5 y 40
#Here is my attempt using IF and AND:
{=MEDIAN(IF(AND(A2:A21=1,B2:B21="x"),C2:C21))} #DEOSN'T WORK: should be 15, but it's 0
#subcomponents of above work fine on their own:
{=MEDIAN(IF(A2:A21=1,C2:C21)) } #equals 25 as expected
{=MEDIAN(IF(B2:B21="x",C2:C21))} #equals 15 as expected
```

How do I make this work and/or is there another approach I should be using??