How to average last 5 values of a column as new numbers entering?
In Excel, you can quickly calculate the average of last 5 values in a column with the Average function, but, from time to time, you need to enter new numbers behind your original data, and you want the average result will be changed automatically as the new data entering. That is to say, you would like to have the average always reflect the last 5 numbers of your data list, even when you add numbers now and then.
- Reuse Anything: Add the most used or complex formulas, charts and anything else to your favorites, and quickly reuse them in the future.
- More than 20 text features: Extract Number from Text String; Extract or Remove Part of Texts; Convert Numbers and Currencies to English Words.
- Merge Tools: Multiple Workbooks and Sheets into One; Merge Multiple Cells/Rows/Columns Without Losing Data; Merge Duplicate Rows and Sum.
- Split Tools: Split Data into Multiple Sheets Based on Value; One Workbook to Multiple Excel, PDF or CSV Files; One Column to Multiple Columns.
- Paste Skipping Hidden/Filtered Rows; Count And Sum by Background Color; Send Personalized Emails to Multiple Recipients in Bulk.
- Super Filter: Create advanced filter schemes and apply to any sheets; Sort by week, day, frequency and more; Filter by bold, formulas, comment...
- More than 300 powerful features; Works with Office 2007-2019 and 365; Supports all languages; Easy deploying in your enterprise or organization.
The following array formulas may help you to solve this problem, please do as follows:
Enter this formula into a blank cell:
=IF(COUNT(A:A),AVERAGE(INDEX(A:A,LARGE(IF(ISNUMBER(A1:A10000),ROW(A1:A10000)),MIN(5,COUNT(A1:A10000)))):A10000),"no data") (A:A is the column which contains the data you used, A1:A10000 is a dynamic range, you can expand it as long as your need, and the number 5 indicates the last n value.), and then press Ctrl + Shift + Enter keys together to get the average of last 5 numbers. See screenshot:
And now, when you input new numbers behind the original data, the average will be changed as well, see screenshot:
Note: If the column of cells contain 0 values, you want to exclude the 0 values from your last 5 numbers, the above formula will not work, here, I can introduce you another array formula to get the average of last 5 non-zero values, please enter this formula:
=AVERAGE(SUBTOTAL(9,OFFSET(A1:A10000,LARGE(IF(A1:A10000>0,ROW(A1:A10000)-MIN(ROW(A1:A10000))),ROW(INDIRECT("1:5"))),0,1))), and then press Ctrl + Shift + Enter keys to get the result you need, see screenshot: