How to use the AVERAGEA function
What is the AVERAGEA function?
The AVERAGEA function returns the average of a group of values. Text and boolean value FALSE evaluates to 0. TRUE to 1. The "A" in AVERAGEA likely stands for "All" to indicate it averages all values after applying the text/logical conversions.
Table of Contents
1. Introduction
What is the average?
The average is a way to calculate central tendency which is the place of the center of a set of numbers in a statistical distribution. The most often used measures to calculate central tendency are:
- Average - arithmetic mean.
- Median - the middle number of a group of numbers.
- Mode - the most frequent item in a group
The average is the arithmetic mean.
What is arithmetic mean?
The arithmetic mean is calculated by dividing the sum of all values by the number of values.
For example, an array contains these values: 3,2,1
The sum is 3 + 2 + 1 equals 6
The number of values is 3.
6/3 equals 2. The average of 3, 2, 1 is 2
What are the differences between arithmetic mean, harmonic mean and geometric mean?
The arithmetic, harmonic, and geometric means are different ways to average data:
Arithmetic mean is calculated by summing values and dividing by count.
Harmonic mean is found by reciprocating values, averaging, then reciprocating.
Geometric mean is calculated by multiplying values and taking the nth root.
When to use:
- Arithmetic mean for typical or normally distributed data
- Harmonic mean for rates and ratios
- Geometric mean for percentages and proportional growth
The choice depends on data characteristics and what the average should represent. Arithmetic mean is most common, while harmonic and geometric means have specialized uses.
What are boolean values?
Boolean values are TRUE and FALSE. The numerical equivalent to TRUE is 1 and FALSE is 0 (zero). Boolean values are generated when a logical expression is evaluated, for example 1=1 returns TRUE where 1="A" returns FALSE.
What is the difference between AVERAGEA function and the AVERAGE function?
The AVERAGEA function includes logical values and text representations of numbers in a reference as part of the calculation.
For example, a cell range contains these vales: 3, FALSE,2, and 1
AVERAGE(3, FALSE,2, 1) returns 2.
3+2+1 = 6
6/3 = 2
AVERAGEA(3, FALSE,2, 1) returns 1.5.
3+0+2+1 = 6
6/4 = 1.5
The AVERAGEA function evaluates 1 for boolean value TRUE and 0 (zero) for FALSE. Text values and formulas that return nothing "" evaluate to 0 (zero).
This table shows the difference between AVERAGEA and AVERAGE functions.
Values | AVERAGEA | AVERAGE |
---|---|---|
Text values | 0 | Ignored |
Empty cells | Ignored | Ignored |
TRUE | 1 | Ignored |
FALSE | 0 | Ignored |
Related AVERAGEA functions
Function | Description |
---|---|
GEOMEAN(number1, [number2], ...) | Returns the geometric mean of values |
HARMEAN(number1, [number2], ...) | Returns the harmonic mean of values |
AVERAGE(number1, [number2], ...) | Returns the arithmetic mean of values |
AVERAGEA(value1, [value2], ...) | Returns arithmetic mean ignoring text |
AVERAGEIF(range, criteria, [average_range]) | Conditional arithmetic mean if criteria met |
AVERAGEIFS(average_range, criteria_range1, criteria1, ...) | Conditional arithmetic mean on multiple criteria |
2. Syntax
AVERAGEA(value1, [value2], ...)
3. Arguments
value1 | Required. Values for which you want to calculate the average. |
[value2] | Optional. Up to 254 additional arguments. |
4. Example 1
This example has 5 values in cell range B3:B7 and they are: Text, 1, 2, TRUE, and FALSE. The reason these values are chosen is because it demonstrates how the AVERAGEA function handles text and boolean values before calculating the average.
Here is how they are processed by the AVERAGE function:
- Text - text strings are converted into a 0 (zero)
- 1 - numbers are not converted.
- 2 - see above.
- TRUE - Boolean value is converted in to number 1.
- FALSE - Boolean value is converted in to number 0. (zero)
This means that text and boolean value FALSE are counted to the total number of items but not added to the total as they are handled as 0's (zeros). However, numbers and boolean value TRUE are counted to the total number of items and added to the total.
Formula in cell D3:
The average formula is AVERAGE = "Sum of all numbers" / "Sum of all observations"
Here is how the calculation is performed in detail:
Value | Number |
Text | 0 |
1 | 1 |
2 | 2 |
TRUE | 1 |
FALSE | 0 |
Total number of items | Total: |
5 | 4 |
0 + 1 + 2 + 1 + 0 = 4/5 = 0.8
5. Example 2
This example demonstrates how to calculate the average of a frequency table containing text values, boolean values and numbers. The image above displays the frequency table in cell range B3:C7 and in the table below.
Frequency | Values |
5 | Text |
3 | 1 |
7 | 2 |
2 | TRUE |
9 | FALSE |
The frequency means the number of times a given value exists in the observed data. For example, Text which is the first value in the frequency table exists 5 times, however, text values are considered 0's (zero). In other words, "Text" corresponds to five 0's in the observed data set.
The next two values are number 1 and 2, they are in the calculation as usual. Number 1 exists 3 times and number 2 exists 7 times based on the frequency table above.
The boolean value TRUE is equal to 1 and exists 2 times. FALSE is 0 (zero) and exists 9 times.
Formula in cell E3:
The AVERAGEA function is not built to handle frequency tables, the formula above is a workaround to handle these kind of calculations. The image above shows a frequency chart based on the frequency table above. It is a column chart with the values on the x-axis and the frequency on the y-axis.
Frequency | Values | Result |
5 | Text | 5 * 0 = 0 |
3 | 1 | 3 * 1 = 3 |
7 | 2 | 7 * 2 = 14 |
2 | TRUE | 2 * 1 = 2 |
9 | FALSE | 9 * 0= 0 |
The total is 0 + 3 + 14 + 2 + 0 = 19
The number of observations is 5 + 3 + 7 + 2 + 9 = 26
The average is 19 / 26 equals approx. 0.7307692
5.1 Explaining formula
Step 1 - Identify text values
The ISTEXT function returns TRUE if argument is text.
Function syntax: ISTEXT(value)
ISTEXT(C3:C7)
Step 2 - Convert text values to 0 and the leave the remaining values as is
The IF function returns one value if the logical test is TRUE and another value if the logical test is FALSE.
Function syntax: IF(logical_test, [value_if_true], [value_if_false])
IF(ISTEXT(C3:C7),0,C3:C7)
Step 3 - Multiply by frequency
The asterisk lets you multiply value to value, it lets you also multiply arrays by arrays.
IF(ISTEXT(C3:C7),0,C3:C7)*B3:B7
Step 4 - Sum numbers
The SUM function allows you to add numerical values, the function returns the sum in the cell it is entered in. The SUM function is cleverly designed to ignore text and boolean values, adding only numbers.
Function syntax: SUM(number1, [number2], ...)
SUM(IF(ISTEXT(C3:C7),0,C3:C7)*B3:B7)
Step 5 - Calculate ratio between the total and the number of observations
The division character lets you divide numbers, the ratio calculated here is the average based on the frequency table described above.
SUM(IF(ISTEXT(C3:C7),0,C3:C7)*B3:B7)/SUM(B3:B7)
6. Function not working
The AVERAGEA function returns
- #NAME? error if you misspell the function name.
- propagates errors, meaning that if the input contains an error (e.g., #VALUE!, #REF!), the function will return the same error.
6.1 Troubleshooting the error value
When you encounter an error value in a cell a warning symbol appears, displayed in the image above. Press with mouse on it to see a pop-up menu that lets you get more information about the error.
- The first line describes the error if you press with left mouse button on it.
- The second line opens a pane that explains the error in greater detail.
- The third line takes you to the "Evaluate Formula" tool, a dialog box appears allowing you to examine the formula in greater detail.
- This line lets you ignore the error value meaning the warning icon disappears, however, the error is still in the cell.
- The fifth line lets you edit the formula in the Formula bar.
- The sixth line opens the Excel settings so you can adjust the Error Checking Options.
Here are a few of the most common Excel errors you may encounter.
#NULL error - This error occurs most often if you by mistake use a space character in a formula where it shouldn't be. Excel interprets a space character as an intersection operator. If the ranges don't intersect an #NULL error is returned. The #NULL! error occurs when a formula attempts to calculate the intersection of two ranges that do not actually intersect. This can happen when the wrong range operator is used in the formula, or when the intersection operator (represented by a space character) is used between two ranges that do not overlap. To fix this error double check that the ranges referenced in the formula that use the intersection operator actually have cells in common.
#SPILL error - The #SPILL! error occurs only in version Excel 365 and is caused by a dynamic array being to large, meaning there are cells below and/or to the right that are not empty. This prevents the dynamic array formula expanding into new empty cells.
#DIV/0 error - This error happens if you try to divide a number by 0 (zero) or a value that equates to zero which is not possible mathematically.
#VALUE error - The #VALUE error occurs when a formula has a value that is of the wrong data type. Such as text where a number is expected or when dates are evaluated as text.
#REF error - The #REF error happens when a cell reference is invalid. This can happen if a cell is deleted that is referenced by a formula.
#NAME error - The #NAME error happens if you misspelled a function or a named range.
#NUM error - The #NUM error shows up when you try to use invalid numeric values in formulas, like square root of a negative number.
#N/A error - The #N/A error happens when a value is not available for a formula or found in a given cell range, for example in the VLOOKUP or MATCH functions.
#GETTING_DATA error - The #GETTING_DATA error shows while external sources are loading, this can indicate a delay in fetching the data or that the external source is unavailable right now.
6.2 The formula returns an unexpected value
To understand why a formula returns an unexpected value we need to examine the calculations steps in detail. Luckily, Excel has a tool that is really handy in these situations. Here is how to troubleshoot a formula:
- Select the cell containing the formula you want to examine in detail.
- Go to tab “Formulas” on the ribbon.
- Press with left mouse button on "Evaluate Formula" button. A dialog box appears.
The formula appears in a white field inside the dialog box. Underlined expressions are calculations being processed in the next step. The italicized expression is the most recent result. The buttons at the bottom of the dialog box allows you to evaluate the formula in smaller calculations which you control. - Press with left mouse button on the "Evaluate" button located at the bottom of the dialog box to process the underlined expression.
- Repeat pressing the "Evaluate" button until you have seen all calculations step by step. This allows you to examine the formula in greater detail and hopefully find the culprit.
- Press "Close" button to dismiss the dialog box.
There is also another way to debug formulas using the function key F9. F9 is especially useful if you have a feeling that a specific part of the formula is the issue, this makes it faster than the "Evaluate Formula" tool since you don't need to go through all calculations to find the issue..
- Enter Edit mode: Double-press with left mouse button on the cell or press F2 to enter Edit mode for the formula.
- Select part of the formula: Highlight the specific part of the formula you want to evaluate. You can select and evaluate any part of the formula that could work as a standalone formula.
- Press F9: This will calculate and display the result of just that selected portion.
- Evaluate step-by-step: You can select and evaluate different parts of the formula to see intermediate results.
- Check for errors: This allows you to pinpoint which part of a complex formula may be causing an error.
The image above shows cell reference B3:B7 converted to hard-coded value using the F9 key. The AVERAGEA function requires non-error values which is not the case in this example. We have found what is wrong with the formula.
Tips!
- View actual values: Selecting a cell reference and pressing F9 will show the actual values in those cells.
- Exit safely: Press Esc to exit Edit mode without changing the formula. Don't press Enter, as that would replace the formula part with the calculated value.
- Full recalculation: Pressing F9 outside of Edit mode will recalculate all formulas in the workbook.
Remember to be careful not to accidentally overwrite parts of your formula when using F9. Always exit with Esc rather than Enter to preserve the original formula. However, if you make a mistake overwriting the formula it is not the end of the world. You can “undo” the action by pressing keyboard shortcut keys CTRL + z or pressing the “Undo” button
6.3 Other errors
Floating-point arithmetic may give inaccurate results in Excel - Article
Floating-point errors are usually very small, often beyond the 15th decimal place, and in most cases don't affect calculations significantly.
Functions in 'Statistical' category
The AVERAGEA function function is one of 73 functions in the 'Statistical' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form