Function Problems

Return or Average the Last Five Matching Scores in Excel 365

Emma BrownEmma Brown Dec 2, 2026 868 views

Question details

Find records that match a criterion and return or average their last five scores.

Return or Average the Last Five Matching Scores in Excel 365
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.
Before you start

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.

Solution 1Recommended

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.

1
Return the scores

Select an empty cell and enter =TAKE(FILTER(H2:H1000,B2:B1000=S11),-5). The results spill into cells below the formula.

2
Calculate the average

In another empty cell, enter =IFERROR(AVERAGE(TAKE(FILTER(H2:H1000,B2:B1000=S11),-5)),"No matching games").

3
Adjust the ranges

Edit B2:B1000 and H2:H1000 in either formula if your data covers different rows, keeping both ranges the same size.

Use FILTER and TAKE to return or average the last five scores
Fewer than five matches: If fewer than five records match, TAKE returns all available matches. The return formula shows an error if there are no matches; the average formula displays the message for any error, not just a missing match.
Work with matching scores in WPS

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. 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. 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. 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. 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)).
Return and average the last five matching recordsOpen and edit Microsoft Excel XLSX and XLS filesUse familiar spreadsheet formulas and a helper column
microsoft office alternative - wps office

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.