# AVERAGEIF - Why one works but another doesn't

#### Domski

##### Well-known Member
Hi there,

Just trying to get my head around something, more out of curiosity than anything else.

I'm using this formula to get averages based on 2 criteria:

{=AVERAGE(IF(Leave_Group=B\$3,IF(Leave_Days>0,Leave_Days)))}

Which works fine.

I'm not a great fan of nested IF statements so assumed you'd be able to do the same thing using:

{=AVERAGE(IF(AND(Leave_Group=B\$3,Leave_Days>0),Leave_Days))}

But it doesn't work.

Can anyone explain why?

### Excel Facts

If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
What are the defintions of Leave_Group and Leave_Days precisely?

Hi,

Sorry, they're just named ranges that I use.

Leave Group = Leavers!\$D\$2:\$D\$3129

Leave Days = Leavers!\$N\$2:\$N\$3129

Dom,

I don't know why AND doesn't work, but without the other IF,

{=AVERAGE(IF((Leave_Group=B\$3)*(Leave_Days>0),Leave_Days))}

Cheers Brian.

Prefer that approach.

Replies
9
Views
489
Replies
10
Views
126
Replies
4
Views
363
Replies
2
Views
270
Replies
1
Views
103

1,217,382
Messages
6,136,238
Members
450,000
Latest member
jgp19

### We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.

### Which adblocker are you using?

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

### Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

### Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back