Return or Average the Last Five Matching Scores in Excel 365
Question details
Find records that match a criterion and return or average their last five scores.

- Product
- Microsoft Excel 365
- Device & OS
- not provided
- Scenario
- A worksheet contains criteria in column B, scores in column H, and the selected criterion in cell S11.
- Observed behavior
- The user wants the five matching scores nearest the bottom of the data range, or their average.
Check that column B contains the criteria, column H contains numeric scores, and S11 contains the criterion to match. Arrange the records so the most recent entries are at the bottom, and adjust both ranges to cover the same rows.
Use FILTER and TAKE to return or average the last five scores
Use Excel 365 dynamic array functions to select the last matching records without a helper column.
Select an empty cell and enter =TAKE(FILTER(H2:H1000,B2:B1000=S11),-5). The results spill into cells below the formula.
In another empty cell, enter =IFERROR(AVERAGE(TAKE(FILTER(H2:H1000,B2:B1000=S11),-5)),"No matching games").
Edit B2:B1000 and H2:H1000 in either formula if your data covers different rows, keeping both ranges the same size.

Find and Average the Last Five Matches in WPS Spreadsheets
Use a helper column in WPS Spreadsheets to number matching records, return their last five scores, and calculate their average.
- 1. Open your workbook: Open the workbook in WPS Spreadsheets. Put the criterion in S11, with matching values in B2:B1000 and numeric scores in H2:H1000; place the newest records at the bottom.
- 2. Number matching records: In an empty helper column, enter =IF(B2=$S$11,COUNTIF($B$2:B2,$S$11),"") in I2, then fill the formula down through I1000.
- 3. Return the last five scores: In K2, enter =IFERROR(INDEX($H$2:$H$1000,MATCH(LARGE($I$2:$I$1000,ROWS($K$2:K2)),$I$2:$I$1000,0)),"") and fill it down through K6. Scores appear from the last matching record upward.
- 4. Average the last five scores: In an empty cell, enter =IF(COUNT(I2:I1000)=0,"No matching games",AVERAGEIF(I2:I1000,">"&MAX(0,MAX(I2:I1000)-5),H2:H1000)).

Frequently Asked Questions
What does the negative 5 in TAKE mean?
In =TAKE(FILTER(H2:H1000,B2:B1000=S11),-5), -5 selects up to five rows from the end of the filtered results.
What happens if fewer than five records match?
TAKE returns all available matching records, and AVERAGE calculates their average. If no records match, the IFERROR average formula displays "No matching games".
Why does the return formula show a spill error?
The FILTER and TAKE formula needs empty cells below it for its results. Clear any contents blocking the spill range or enter the formula in a larger empty area.
Does the formula use dates to determine the latest records?
No. TAKE selects matches nearest the bottom of the specified range. Sort the records by date first if the latest records are not already at the bottom.




