# Averaging Values that Correspond with the X Largest Values in a Dynamic Range

Problem:

Column A contains dates of recent basketball games.
Column B contains the number of points scored by a particular player during each game.
Whenever a new game is played, the relevant dates and scores are added to the sheet.
We want to create formulas that will average the most recent X number of scores for each value for X listed in column D. The formulas should automatically update whenever new data is added.

Solution:

Use the AVERAGE, IF, and LARGE functions in the following Array formula:
{=AVERAGE(IF(\$A\$2:\$A\$65000>=LARGE(\$A\$2:\$A\$65000,D2),\$B\$2:\$B\$65000))}

Terms and Conditions of use

The applications/code on this site are distributed as is and without warranties or liability. In no event shall the owner of the copyrights, or the authors of the applications/code be liable for any loss of profit, any problems or any damage resulting from the use or evaluation of the applications/code.