A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
If you have Microsoft 365 or use Excel Online:
=AVERAGE(TAKE(FILTER(A1:A17, A1:A17<>""),-2))
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi,
I have the formula to calculate the sum and average of the last 2 values in Column A if there are no gaps in the data. This works if I add further values into the column.
Formula under 'Sum': =SUM(OFFSET(A1,COUNT(A1:A17)-2,0,2))
Formula under 'Average': =AVERAGE(OFFSET(A1,COUNT(A1:A17)-2,0,2))
| 1.00 | Sum | Average | |||
|---|---|---|---|---|---|
| 2.00 | Last 2 values | 9.00 | 4.50 | ||
| 3.00 | |||||
| 4.00 | |||||
| 5.00 | |||||
However, when there are gaps in the data, the above formulae do not work in calculating the sum/average of the last 2 values in the Column:
| 1.00 | Sum | Average | |||
|---|---|---|---|---|---|
| 2.00 | Last 2 values | 5.00 | 5.00 | ||
| 3.00 | |||||
| 4.00 | |||||
| 5.00 | |||||
| 7.00 | |||||
As you can see, the sum should be 5+7=12 and the average should be of 5 and 7 (6),
Is there a formula I can use which would automatically discount blank cells?
Thank you!
A family of Microsoft spreadsheet software with tools for analyzing, charting, and communicating data
Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.
Answer accepted by question author
If you have Microsoft 365 or use Excel Online:
=AVERAGE(TAKE(FILTER(A1:A17, A1:A17<>""),-2))
Thank you so much!