Averageif Always Returns the Wrong Answer

Coachcasa

New Member
Joined
Feb 1, 2021
Messages
34
Office Version
  1. 2016
Platform
  1. MacOS
Hi. I'm trying to use an averageif formula and I think I have it correct, but it keeps returning the same value that is wrong. Here is the formula I'm using:

=AVERAGEif($E$2:$E$1000,"George H.W. Bush",$F$2:$J$1000)

Here is the table I'm pulling from:

1EFGHIJ
2George H.W. Bush34243
3George H.W. Bush12345
4George W. Bush44353

It keeps giving me an answer of 2, but I know the proper answer should be 3.1. Even if it averaged all three rows it should still be 3.33. I'm just using this as a test table, so I don't have any info below row 4 right now, but it will populate down. My formula is located in cell K2. I tried putting a list of presidents in K3-K23 and using the cell reference instead of the name in quotes, but that just gave me an error. Can anyone help me here and explain what I'm doing wrong? Thanks.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
For functions like AVERAGEIF (and COUNTIFS, SUMIF etc) all the ranges need to be the same size and shape, which is why yours is not working. You could do something like:

Excel Formula:
=SUMPRODUCT(($E$2:$E$1000="George H.W. Bush")*($F$2:$J$1000))/(COUNTIF($E$2:$E$1000,"George H.W. Bush")*5)
 
Upvote 0
The cells that are evaluated for the average are mapped to the same shape as the range for the matching criteria. So in your case, the average is computed using $F$2:$F$1000.
 
Upvote 0
For functions like AVERAGEIF (and COUNTIF, SUMIF etc) all the ranges need to be the same size and shape
Just a technicality: For AVERAGEIF (and SUMIF) the ranges do not have to be the same size and shape, that is, you will not get an error if they are not. But if they are not, it will use the size and shape of the first argument to resize the third argument for calculating the average, and this is usually not what the user intends. (COUNTIF only specifies one range.)
 
Upvote 0
For functions like AVERAGEIF (and COUNTIF, SUMIF etc) all the ranges need to be the same size and shape, which is why yours is not working. You could do something like:

Excel Formula:
=SUMPRODUCT(($E$2:$E$1000="George H.W. Bush")*($F$2:$J$1000))/(COUNTIF($E$2:$E$1000,"George H.W. Bush")*5)
When you say the same size and shape are you meaning that every cell has to have the same
 
Upvote 0
Thanks, everyone for your answers and thank you Rory for giving me a formula that works! I never realized this, so I've learned something new today.
 
Upvote 0
The implication was that they need to be the same size and shape for the function to work properly. :)
 
Upvote 0
When you say the same size and shape are you meaning that every cell has to have the same
No, just that if the first range is 1 column by 100 rows, the other ranges should also be 1 column by 100 rows. As Jeff pointed out, the function will silently resize your ranges to suit that restriction - so for example if you typed:

Excel Formula:
=SUMIF(A1:A100,"test",B1)

that would actually be evaluated as:

Excel Formula:
=SUMIF(A1:A100,"test",B1:B100)
 
Upvote 0

Forum statistics

Threads
1,216,579
Messages
6,131,531
Members
449,654
Latest member
andz

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