Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • Excel Line Chart
  • Subtotal function in Excel
  • How to combine 2 or more chart types in a single chart in Excel
  • Get column name from index in Excel Table
  • How to count table rows in Excel

References

  • How to use Excel MMULT Function
  • How to use Excel ROW Function
  • Offset in Excel
  • Count unique text values with criteria
  • How to get address of first cell in range in Excel

Data Validations

  • Excel Data validation allow uppercase only
  • Excel Data validation whole percentage only
  • Excel Data validation require unique number
  • Excel Data validation with conditional list
  • Excel Data validation number multiple 100

How to calculate average last N values in a table in Excel

by

To calculate the average for the last N values n an Excel table (i.e. last 3 rows, last 5 rows, etc.) you can use the AVERAGE function together with the INDEX and ROWS functions. See example below:

Formula

=AVERAGE(INDEX(table[column],ROWS(table)-(N-1)):INDEX(table[column],ROWS(table)))

Explanation

In the example shown, the formula in F5 is:

=AVERAGE(INDEX(Table1[Sales],ROWS(Table1)-(F4-1)):INDEX(Table1[Sales],ROWS(Table1)))

How this formula works

This formula is a good example of how structured references can make working with data in Excel much easier. At the core, this is what we’re doing:

=AVERAGE(first:last)

where “first” is a reference to the first cell to include in the average and “last” is a reference to the last cell to include. The result is a range that includes the N cells to average.

Worked Example:   How to get relative row numbers in a range in Excel

To get the first cell in the range, we use INDEX like this:

INDEX(Table1[Sales],ROWS(Table1)-(F4-1))

The array is the entire Sales column, and row number worked by subtracting (n-1) from total rows.

Worked Example:   How to get random value from list or table in Excel

In the example, F4 contains 3, so the row number is 10-(3-1) = 8. With a row number of 8, INDEX returns C12.

Worked Example:   INDEX and MATCH descending order in Excel

To get the last cell we use INDEX again like this:

INDEX(Table1[Sales],ROWS(Table1))

There are 10 rows in the table, so INDEX returns C14.

The AVERAGE function then returns the average of C12:C14, which is $78.33.

Post navigation

Previous Post:

How to generate random date between two dates in Excel

Next Post:

Popularly Used Excel Functions and their examples

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • IF function: Description, Usage, Syntax, Examples and Explanation
  • Invoice status with nested if in Excel
  • SWITCH function: Description, Usage, Syntax, Examples and Explanation
  • How to use Excel OR Function
  • How to use IFS function in Excel

Date Time

  • Generate series of dates by weekends in Excel
  • How to get Holiday Date from Year in Excel
  • How to calculate workdays per month in Excel
  • Convert decimal seconds to Excel time
  • Display Days in month in Excel

Grouping

  • Group numbers with VLOOKUP in Excel
  • Calculate conditional mode with criteria in Excel
  • Map text to numbers in Excel
  • How to randomly assign people to groups in Excel
  • Group arbitrary text values in Excel

General

  • AutoRecover file that was never saved in Excel
  • How to get amount with percentage in Excel
  • 231 Keyboard Shortcut Keys In Excel
  • How to Delete Cells, Row and Rows in Excel
  • How to choose page/paper size in Excel before Printing
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning