How To Calculate Average (mean) in Excel?
To calculate the average without using AVAERAGE function, we can sum all numeric values and divides by the count of numeric values. We can use SUM and COUNT functions like this:
= SUM(A1:A5)/COUNT(A1:A5) // manual average calculation
Here : SUM function is used to add multiple numeric values within different cells and
To count total number of cells containing only numbers, we use EXCEL function COUNT.
Let us look at an example :
Here we are calculating the average age of all the customers from row 2 to row 12 using the formula : SUM(B2:B6)/COUNT(B2:B12)
Excel AVERAGE function :
To calculate the average (or mean) of the given arguments, we use the excel function average. In AVERAGE ,maximum 255 individual arguments can be given and the arguments which can include numbers / cell references/ ranges/ arrays or constants.
Syntax : = AVERAGE(number1, [number2], ...)
- Number1 (Required) : It specifies the Range, cell references or first number for which we want the average to be calculated.
- Number2 (Optional) : Numbers, cell references or ranges which are additional for which you want the average.
For example: If the range C1:C35 contains numbers, and we want to get the average of those numbers, then the formula is : AVERAGE(C1:C35)
- Those values in a range or cell reference argument which has text, logical values, or empty cells, are ignored in calculating average.
- Cells with the value zero are included.
- Error occur if the arguments have an error value or text that cannot be translated into numbers.
Let us look at the same example to calculate the average age of all the customers from row 2 to row 12 using the formula : AVERAGE(B2:B12).
If we have a row containing non- numeric value, it is ignored as :
Here average of rows from B2 to B6 was taken, but B5 is not included in the average as it contain non numeric data.
You can see that in column B : we have done B7 = AVERAGE (B2 : B6) .
So average() will evaluate as = 9+8+8+9 / 4 = 8.5
Excel AVERAGEA function:
To calculate the average (or mean) of the given arguments, we use the Excel function AVERAGEA. The AVERAGEA function is not same as the AVERAGE function, it is different as AVERAGEA treats TRUE as a value of 1 and FALSE as a value of 0.
The AVERAGEA function was introduced in MS Excel 2007( Not in old versions) & it is a statistics related function.
It finds an average of cells with any data (numbers, Boolean and text values) whereas the average() find an average of cells with numbers only.
Syntax: =AVERAGEA(value1, [value2], …)
Value1 is required, subsequent values are optional.
In AVERAGEA ,up to 255 individual arguments can be given & the arguments which can include numbers / cell references/ ranges/ arrays or constants.
Here , you can see that :
- In column B : we have done B7 = AVERAGEA(B2 : B6). So averagea() will evaluate as = 9+9+9+1+8 / 5 = 7.2 (True is replaced by 1 in calculating).
- In column C : we have done C7 = AVERAGEA(C2 : C6) .
So averagea() will evaluate as = 9+9+9+0+8 / 5 = 7 (False is replaced by 0 in calculating)
Note: AVERAGE just skips these values (true/false) during calculation
So, if you do not want to include logical values (True/False), use the AVERAGE function.
Excel AVERAGEIF function :
To calculate the average (or mean) of the given arguments hat meet a (single) given criteria., we use the Excel function AVERAGEIF.
Syntax : = AVERAGEIF(range, criteria, [average_range])
- Range : Required, It specifies the range of cells that needs to be tested against the given criteria.
- Criteria : Required , the condition used to determine which cells to average. The criteria specified here can be in the form of a number, text value, logical expression, or cell reference, e.g. 5 or “>5” or “cat” or A2.
- Average_range : Optional , The set of cells on which the average needs to be calculated on. If not included , the range is used to calculate the average on.
1. AVERAGEIF ignores an empty cell in average_range.
2. AVERAGEIF ignores Cells in range that contain TRUE or FALSE.
3. AVERAGEIF returns the #DIV0! error value, if range is a blank or text value
4. AVERAGEIF treats cell value as a 0 value, If a cell in criteria is empty.
Example 1 :Let us look at an example that calculate average of non negative ages of customers in the rows 2 to 6 :
Here : The negative age is not included in the average .
Average is calculated as = (9+8+9+9) / 4 = 8.75
Example 2 : To get the average of price of the product named : “Apple” :
Here in the criteria, we specified “Apple” & in range we specified A2: A6 & we are doing average on B2:B6 (Price), so in the range A2: A6, wherever Apple comes, include its price for calculating average.
Here, average is calculated as : 100 + 200 / 2 = 150.
Excel AVERAGEIFS function
To calculate the average (or mean) of the given arguments that meets multiple criteria, AVERAGEIFS is used.
= AVERAGEIFS(average_range, criteria1_range1, criteria1, [criteria2_range2, criteria2], ...)
- average_range : Required, The range of cells that you wish to average.
- criteria1_range2, criteria2_range2, … criteria1_range2 is required The range to apply the associated criteria against.
- criteria1, criteria2, … criteria1 is mandatory, further more criteria are optional.
Note : The criteria to apply against the associated range. Criteria1 is the criteria to use on range1 and the criteria2 is the criteria to use on range2 and so on.
To calculate the average price of of Product named “Apple” and whose price > 99 :
Here 2 conditions are met : 1st condition range – A2:A6 and criteria is “Apple”, 3 rows matches the criteria
2nd Condition range – B2:B6 and criteria is “>99” & there are 3 rows with product name apple & with price price >99
So, the average is = (100 + 120 + 200) / 3 = 140
How to average cells by multiple criteria with OR logic?
OR Logical Operator
This logic test multiple conditions at the same time. OR returns either TRUE or FALSE. For example, to test A1 contains “x” or “y”, use =OR (A1=”x”, A1=”y”).
To see that the product in a particular row is an apple/ an orange , we can :
Here we can see that the product in the range A2 to A6 having name : Apple / orange evaluates true result in the column B2 to B6. Now we can use this sub-result as a part of our function AVERAGEIFS().
To calculate the average price of the product named Apple/ Orange having price > 99 :
We use the method as :
As you can see that to add OR with the AVERAGEIFS() , we add a new column that takes the result of the OR query , i.e., either true/false . Based on that answer , we are calculating the average by matching True for the range B2:B6.
So the average comes out to be
= (100 + 120 + 200) / 3 = 140.
We considered only those price which were > 99 for the product : Apple / Orange.