Based on the data in columns d and k below, what formula will calculate the average compensation

The tutorial will teach you how to find an average in Excel with or without formulas and round the results to as many decimal places as you want.

In Microsoft Excel there are a handful of different functions for calculating the average for a set of numeric values. Moreover, there is an instant non-formula way. On this page, you will find a quick overview of all the methods illustrated with examples of use and best practices. All the functions discussed in this tutorial work in any version of Excel 365 through Excel 2007.

In everyday life, the average is a number expressing the typical value in a dataset of data. For example, if a few athletes have run a 100m sprint, you may want to know the average result - i.e. how much time most sprinters are expected to take to complete the race.

In mathematics, the average is the middle or central value in a set of numbers, which is calculated by dividing the sum of all the values by their number.

In the above example, assuming the first athlete covered the distance in 10.5 seconds, the second needed 10.7 seconds, and the third took 11.2 seconds, the average time would be 10.8 seconds:

(10.5+10.7+11.2)/3 = 10.8

In Excel worksheets, you do not need to perform manual calculations - powerful Excel functions will do all the work behind the scenes and deliver the result in no time. Before exploring the specialized functions in detail, let's learn a quick and amazingly simple non-formula way.

To quickly find an average without a formula, use Excel's status bar:

  1. Select the cells or ranges you want to average. For non-contiguous selections, use the Ctrl key.
  2. Look at the status bar at the bottom of the Excel window, which provides the essential information about the currently selected cells. One of the values that Excel calculates automatically is the average.

The result is shown in the image below:

Based on the data in columns d and k below, what formula will calculate the average compensation

In math, to find the arithmetic mean of a list of numbers, you need to add up all the values, and then divide the sum by how many numbers there are in the list. In Excel, this can be done using the SUM and COUNT functions, respectively:

SUM(range)/COUNT(range)

For the range of numbers below, the formula goes as follows:

=SUM(B3:B12)/COUNT(B3:B12)

As you can see, the result of the formula exactly matches the average value in the status bar.

Based on the data in columns d and k below, what formula will calculate the average compensation

In practice, you will hardly ever need to do a manual average in your worksheets. However, it may be useful to re-check the result of your average formula in case of doubt.

And now, let's take a look at how you can do average in Excel using the functions specially designed for the purpose.

You use the Excel AVERAGE function to get an average of all numbers in the specified cells or ranges.

AVERAGE(number1, [number2], …)

Where number1, number2, … are numeric values for which you want to find the average. Up to 255 arguments can be included in a single formula. The arguments can be supplied as numbers, references, or named ranges.

AVERAGE is one of the most straightforward and easy-to-use functions in Excel.

To calculate an average of numbers, you can type them directly in a formula or supply the corresponding cell or range references.

For example, to average 2 ranges and 1 individual cell below, the formula is:

=AVERAGE(B4:B6, B8:B10, B12)

Based on the data in columns d and k below, what formula will calculate the average compensation

Apart from numbers, the Excel AVERAGE function can find an average of other numeric values such as percentages and times.

As you've just seen, using the AVERAGE function in Excel is easy. However, to get a correct result, you need to clearly understand what values are included in the average and what are ignored.

Included:

  • Cells with zero values (0)
  • Logical values TRUE and FALSE typed directly into the list of arguments. For example, the formula AVERAGE(TRUE, FALSE) returns 0.5, which is the mean of 1 and 0.

Ignored:

  • Empty cells
  • Text strings
  • Cells containing Boolean values TRUE and FALSE

For more information, please see How to use AVERAGE function in Excel.

The Excel AVERAGEA function is similar to AVERAGE in that it calculates the arithmetic mean of the values in its arguments. The difference is that AVERAGEA includes all non-empty cells in a calculation, whether they contain numbers, text, logical values, or empty strings returned by other functions.

AVERAGEA(value1, [value2], …)

Where value1, value2, … are values, arrays, cell references or ranges that you want to average. The first argument is required, others (up to 255) are optional.

As mentioned above, the AVERAGEA function processes different value types such as numbers, text strings and logical values. And here's how they are evaluated:

Included:

  • Text values evaluate as 0.
  • Zero-length strings ("") evaluate as 0.
  • Boolean value TRUE evaluates as 1 and FALSE as 0.

Ignored:

For example, the below formula returns 1, which is the average of 2 and 0.

=AVERAGEA(2, FALSE)

The following formula returns 1.5, which is the average of 2 and 1.

=AVERAGEA(2, TRUE)

The image below demonstrates the AVERAGE and AVERAGEA formulas applied to the same list of values and different results they return:

Based on the data in columns d and k below, what formula will calculate the average compensation

To get the average of all cells in the specified range that meet a certain condition, use the AVERAGEIF function.

AVERAGEIF(range, criteria, [average_range])

The AVERAGEIF function has the following arguments:

  • Range (required) - the range of cells to test against a given criteria.
  • Criteria (required) - the condition that should be met.
  • Average_range (optional) - the cells to average. If omitted, then range is averaged.

The AVERAGEIF function is available in Excel 2007 - Excel 365. In earlier versions, you can build your own AVERAGE IF formula.

And now, let's see how you can use the Excel AVERAGEIF function to average cells based on the condition you specify.

Suppose you have scores for different subjects in C3:C15 and you wish to find an average math score. This can be done with the following formula:

=AVERAGEIF(B3:B15, "math", C3:C15)

Instead of "hardcoding" the condition directly in a formula, you can type it in a separate cell (F3) and refer to that cell in the criteria:

=AVERAGEIF(B3:B15, F3, C3:C15)

Based on the data in columns d and k below, what formula will calculate the average compensation

For more formula examples, please see Excel AVERAGEIF function.

To do average with two or more conditions, use the plural counterpart of AVERAGEIF - the AVERAGEIFS function.

AVERAGEIFS(average_range, criteria_range1, criteria1, [criteria_range2, criteria2], …)

The function has the following syntax:

  • Average_range (required) - the range to average.
  • Criteria_range (required) - the range to be tested against criteria.
  • Criteria (required) - the condition that determines which cells to average. It can be supplied in the form of a number, logical expression, text value, or cell reference.

1 to 127 criteria_range / criteria pairs can be supplied. The first pair is required, subsequent ones are optional.

In essence, you use AVERAGEIFS similarly to AVERAGEIF, except that more than one condition can be tested within a single formula.

Supposing some students did not take tests in certain subjects and have zero scores. You aim to find an average score in a specific subject ignoring zeros.

To accomplish the task, you build an AVERAGEIFS formula with two criteria:

  • Define the range to average (C3:C15).
  • Specify the range to check against the 1st condition (B3:B15 - items).
  • Express the 1st condition ("math" or F3 - the target item enclosed in quotation marks or reference to the cell containing the item).
  • Specify the range to check against the 2nd condition (C3:C15 - scores).
  • Express the 2nd condition (">0" - greater than zero).

By assembling the above components together, we get the following formula:

=AVERAGEIFS(C3:C15, B3:B15, "math", C3:C15, ">0")

Or

=AVERAGEIFS(C3:C15, B3:B15, F3, C3:C15, ">0")

The image below makes it clear that only two cells (C6 and C10) meet both conditions, and therefore only these cells are averaged.

Based on the data in columns d and k below, what formula will calculate the average compensation

For more information, check out Excel AVERAGEIFS function.

Excel AVERAGEIF and AVERAGEIFS functions have much in common, in particular which values they calculate and which ignore:

  • In the average range, empty cells, text values, logical values TRUE/FALSE are ignored.
  • In criteria, empty cells are treated as zero values.
  • The wildcard characters such as question mark (?) and asterisk (*) can be used in criteria for partial match.
  • If no cell meets all of the specified criteria, a #DIV0! error occurs.

In terms of functionality, the most essential difference is that AVERAGEIF can only handle one condition while AVERAGEIFS one or more criteria. Also, there are a couple of technical differences related to average_range.

  • With AVERAGEIF, average_range is the last and optional argument. In AVERAGEIFS formulas, it is the first and required argument.
  • With AVERAGEIF, average_range does not necessarily have to be the same size as range because the actual cells to be averaged are determined by the size of the range argument - the upper left cell of average_range is taken as the starting point, and as many cells are averaged as included in the range argument. AVERAGEIFS requires each criteria_range to be of the same size and shape as average_range, otherwise a #VALUE! error occurs.

Since the Excel AVERAGEIFS function always works with the AND logic (all criteria must be TRUE), you will have to construct your own formula to average cells with the OR logic (any single criterion must be TRUE).

Here's the generic formula to average if cell is X or Y.

AVERAGE(IF(ISNUMBER(MATCH(range, {criteria1, criteria2,…}, 0)), average_range))

Now, let's see how it works in practice. In the table below, suppose you want to find an average score of two subjects, Biology and Chemistry, which are input in cells F3 and F4. This can be done with the following array formula:

=AVERAGE(IF(ISNUMBER(MATCH(B3:B15, {"biology", "chemistry"}, 0)), C3:C15))

Translated into a human language, the formula says: average cells in C3:C15 if a corresponding cell in B3:B15 is either "Biology" or "Chemistry".

Instead of the hardcoded criteria, you can use a range reference (F3:F4 in our case):

=AVERAGE(IF(ISNUMBER(MATCH(B3:B15, F3:F4, 0)), C3:C15))

For the formula to work correctly, please remember to press Ctrl + Shift + Enter in Excel 2019 and lower. In dynamic array Excel (365 and 2021), a regular Enter hit will suffice:

Based on the data in columns d and k below, what formula will calculate the average compensation

How this formula works:

For our curious and thoughtful readers who want not only to use a formula but understand what they are doing, here's a detailed explanation of the logic.

At the core of the formula, the IF function determines which values in the source range match any of the specified criteria and passes those values to the AVERAGE function. Here's how:

The MATCH function uses the subject names in B3:B15 as the lookup values and compares each of those values against the lookup array in F3:F4 (our target subjects). The 3rd argument (match_type) is set to 0 to look for exact match:

MATCH(B3:B15, F3:F4, 0)

When a match is found, MATCH returns its relative position in the lookup array, otherwise an #N/A error:

{1;2;1;#N/A;1;#N/A;2;#N/A;1;2;2;1;#N/A}

The ISNUMBER function converts numbers to TRUE and errors to FALSE:

{TRUE;TRUE;TRUE;FALSE;TRUE;FALSE;TRUE;FALSE;TRUE;TRUE;TRUE;TRUE;FALSE}

This array goes to the logical test of IF. In the full form, the logical test should be written like this:

IF(ISNUMBER(MATCH(B3:B15, F3:F4, 0))=TRUE

For the sake of brevity, we omit the =TRUE part because it's implied.

By setting the value_if_true argument to C3:C15, you tell the IF function to replace TRUE's with the actual values from C3:C15:

{89;78;75;FALSE;64;FALSE;62;FALSE;78;56;93;88;FALSE}

This final array is handed over to the AVERAGE function that calculates an arithmetic mean of numbers ignoring logical values.

When calculating an average in Excel, the result is often a number with multiple decimal places. In case you want to display fewer decimal digits or round an average to an integer, use one of the following solutions.

To round only the displayed average without changing the underlying value, the fastest way is to utilize the Decrease Decimal command on the Home tab, in the Number group:

Based on the data in columns d and k below, what formula will calculate the average compensation

The number of decimal places can also be specified in the Format Cells dialog box. To have it done, select the formula cell and press Ctrl + 1 to open the Format Cells dialog. Then, switch to the Number tab, and type the number of places you want to show in the Decimal places box.

Like the previous method, this changes only the display format. When referring to the average cell in other formulas, the original non-rounded value will be used in all calculations.

Based on the data in columns d and k below, what formula will calculate the average compensation

For full details, please see Round numbers by changing cell format.

To round the calculated value itself, wrap your average formula in one of the Excel rounding functions.

In most situations, you'd use the ROUND function that follows the general math rules for rounding. In the 1st argument (number), nest the AVERAGE, AVERAGEIF or AVERAGEIFS function. In the 2nd argument (num_digits), specify the number of decimal places to round the average to.

For example, to round off an average to the nearest integer, the formula is:

=ROUND(AVERAGE(B3:B15), 0)

To round an average to one decimal place, this is the formula to use:

=ROUND(AVERAGE(B3:B15), 1)

To round an average to two decimal places, this one will work:

=ROUND(AVERAGE(B3:B15), 2)

Based on the data in columns d and k below, what formula will calculate the average compensation

Tip. For rounding up, use the ROUNDUP function; for rounding down - the ROUNDDOWN function.

That is how you can do average in Excel. Below there are links to the related tutorials that discuss more specific cases of average, hope you will find them helpful. Thank you for reading!

Calculate average in Excel - examples (.xlsx file)