How can I use SUBTOTAL with AVERAGEIF in Excel? 2

How can I use SUBTOTAL with AVERAGEIF in Excel?

SUBTOTAL and AVERAGEIF are two useful functions in Excel that can be used together to efficiently calculate average values in a large data set. SUBTOTAL allows for the calculation of various statistical functions, such as AVERAGE, while also being able to ignore hidden or filtered data. AVERAGEIF, on the other hand, allows for the calculation of the average value based on a specified criteria. By combining these two functions, one can easily calculate the average of a subset of data that meets a certain condition. This can be particularly useful for analyzing and summarizing data in a large dataset, making it a valuable tool for data analysis in Excel.

Use SUBTOTAL with AVERAGEIF in Excel


You can use the following formula to combine the SUBTOTAL and AVERAGEIF functions in Excel:

=AVERAGE(IF(SUBTOTAL(2,OFFSET(C2,ROW(C2:C11)-ROW(C2),0)),IF(B2:B11="Guard",C2:C11)))

This particular formula allows you to calculate the average of values in the range C2:C11 where the corresponding value in the range B2:B11 is equal to “Guard” even after that range of cells has been filtered in some way.

The following example shows how to use this formula in practice.

Example: How to Use SUBTOTAL with AVERAGEIF in Excel

Suppose we have the following dataset that contains information about various basketball players:

Next, let’s filter the data to only show the rows where the players are in the West conference.

To do so, highlight the cell range A1:C11. Then click the Data tab along the top ribbon and click the Filter button.

Then click the dropdown arrow next to Conference and make sure that only the box next to West is checked, then click OK:

The data will automatically be filtered to only show the rows where the Conference column is equal to West:

If we attempt to use the AVERAGEIF() function to calculate the average of the values in the Points column where the value in the Position column is equal to “Guard”, it will actually return the average of points for the rows equal to “Guard” in the original dataset:

Instead, we need to use the following formula:

=AVERAGE(IF(SUBTOTAL(2,OFFSET(C2,ROW(C2:C11)-ROW(C2),0)),IF(B2:B11="Guard",C2:C11)))

The following screenshot shows how to use this formula in practice:

This formula returns the correct average of 21.25.

We can confirm this is correct by manually calculating the average of the points values for the rows where the Position column is equal to “Guard”:

Average of Points for Guards: (12 + 28 + 30 + 15) / 4 = 21.25.

Additional Resources

The following tutorials explain how to perform other common operations in Excel:

Cite this article

stats writer (2024). How can I use SUBTOTAL with AVERAGEIF in Excel?. PSYCHOLOGICAL SCALES. Retrieved from https://scales.arabpsychology.com/stats/how-can-i-use-subtotal-with-averageif-in-excel/

stats writer. "How can I use SUBTOTAL with AVERAGEIF in Excel?." PSYCHOLOGICAL SCALES, 28 Jun. 2024, https://scales.arabpsychology.com/stats/how-can-i-use-subtotal-with-averageif-in-excel/.

stats writer. "How can I use SUBTOTAL with AVERAGEIF in Excel?." PSYCHOLOGICAL SCALES, 2024. https://scales.arabpsychology.com/stats/how-can-i-use-subtotal-with-averageif-in-excel/.

stats writer (2024) 'How can I use SUBTOTAL with AVERAGEIF in Excel?', PSYCHOLOGICAL SCALES. Available at: https://scales.arabpsychology.com/stats/how-can-i-use-subtotal-with-averageif-in-excel/.

[1] stats writer, "How can I use SUBTOTAL with AVERAGEIF in Excel?," PSYCHOLOGICAL SCALES, vol. X, no. Y, ص Z-Z, June, 2024.

stats writer. How can I use SUBTOTAL with AVERAGEIF in Excel?. PSYCHOLOGICAL SCALES. 2024;vol(issue):pages.

Download Post (.PDF)
Slide Up
x
PDF
Scroll to Top