I would like to find a formula that enables me to calculate at once what the following two formulas calculate individually. The formula would have to ignore blank cells. 

1) A formula that enables me to average the nth last entries in a column and that ignores blank cells (entered using CTRL+SHIFT+ENTER)

```
=AVERAGE(IF(ROW(A1:A10)>=LARGE(IF(A1:A10,ROW(A1:A10)),nth),IF(A1:A10,A1:A10)))

```

2) A formula that averages values if a certain condition is met in an adjacent column (entered using CTRL+SHIFT+ENTER)

```
=AVERAGE(IF(A1:A10="CONDITION",B1:B10))

```

Of course, I would have to manually input the "nth value" as well as the condition.

This example demonstrates what I would like to accomplish (see text below)

![enter image description here](https://i.stack.imgur.com/BaILj.png)

What would the average be for the last two entries where the condition is "Blue"? (7.5)

What would the average be for the last three entries where the condition is "Red"? (7)

etc.

Again please note the blank cells.