Average IF Formula

randolphoralph

Board Regular
Joined
Dec 24, 2008
Messages
126
I am trying to use the formula below to return an average. The formula is returning #DIV/O! error instead of the average. I have checked the data in 'Data'!$K$2:$K$57592 and the formula does not divide by zero.

Code:
=[FONT=Times New Roman]AVERAGE(IF(('Data'!$E$2:$E$57592=$A4)*('Data'!$E$2:$E$57592=$A5)*('Data'!$E$2:$E$57592=$A6)*('Data'!$E$2:$E$57592=$A7)*('Data'!$E$2:$E$57592=$A8)*('Data'!$E$2:$E$57592=$A9)*('Data'!$E$2:$E$57592=$A10)*('Data'!$E$2:$E$57592=$A11)*('Data'!$E$2:$E$57592=$A12)*('Data'!$E$2:$E$57592=$A13)*('Data'!$E$2:$E$57592=$A14)*('Data'!$E$2:$E$57592=$A15)*('Data'!$I$2:$I$57592=BD$1)*('Data'!$K$2:$K$57592<>"")*('Data'!$A$2:$A$57592="Yes"),'Data'!$K$2:$K$57592))[/FONT]

When I change the formula to not be equal to A4-A15 the formula works and returns the correct average.

Code:
=[FONT=Times New Roman]AVERAGE(IF(('Data'!$E$2:$E$57592[COLOR=red]<>[/COLOR]$A4)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A5)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A6)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A7)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A8)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A9)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A10)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A11)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A12)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A13)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A14)*('Data'!$E$2:$E$57592[COLOR=#ff0000]<>[/COLOR]$A15)*('Data'!$I$2:$I$57592=BD$1)*('Data'!$K$2:$K$57592<>"")*('Data'!$A$2:$A$57592="Yes"),'Data'!$K$2:$K$57592))[/FONT]

I am not sure what the issue is. Can anyone provide some insight?
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
You would be better off using a range (instead of linking the <> to individual cells)

This array formula (Press Ctrl+Shift+Enter NOT just Enter) will exclude items from a range when summing. Combine this with a count and you can produce an average

=SUM(IF(C1:C6<>A1:A6,D1:D6,0))

The range that contains the ID
The range that contains items to exclude (IDs to exclude)
The range to SUM

Try it out and see if this can be worked. If not SUMPRODUCT comes to mind
 
Upvote 0
NOT TESTED

You could try this. This again is an array formula

=SUM(IF('Data'!$E$2:$E$57592<>A4:A15,'Data'!$K$2:$K$57592,0))/SUM(IF('Data'!$E$2:$E$57592<>A4:A15,1,0))
 
Upvote 0
I tried the following and it still does not provide the average.

=AVERAGE(IF(('Data'!$E$2:$E$57592=$A4:$A15)*('Data'!$I$2:$I$57592=BD$1)*('Data'!$K$2:$K$57592<>"")*('Data'!$A$2:$A$57592="Yes"),'Data'!$K$2:$K$57592))
 
Upvote 0
I think that the issue I am having is that $A4-$A15 should be "Or" and not "And" for the IF formula, but I am not sure how to change the formula to reflect that.
 
Upvote 0
I have done some additional testing and the problem begins when I am trying to look at more than one cell in Column A.

The following formula worked and returned the correct average.

=AVERAGE(IF(('Data'!$E$2:$E$57592=$A4)*('Data'!$I$2:$I$57592=BD$1)*('Data'!$K$2:$K$57592<>"")*('Data'!$A$2:$A$57592="Yes"),'Data'!$K$2:$K$57592))


When I added the part in red I am getting the #DIV/O! error.

=AVERAGE(IF(('Data'!$E$2:$E$57592=$A4)*('Data'!$E$2:$E$57592=$A5)*('Data'!$I$2:$I$57592=BD$1)*('Data'!$K$2:$K$57592<>"")*('Data'!$A$2:$A$57592="Yes"),'Data'!$K$2:$K$57592))
 
Upvote 0
Also, try and manually filter to represent the same record.

It may be that there are no items left (to average) after all of the exclusions.
 
Upvote 0

Forum statistics

Threads
1,224,516
Messages
6,179,231
Members
452,898
Latest member
Capolavoro009

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.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

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

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

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
Back
Top