Hits: 61

# (Excel examples for Beginners)

In this end-to-end excel example, you will learn – Excel formula for Beginners – How to Average last 5 values in columns in Excel.

### Generic formula

`=AVERAGE(OFFSET(firstcell,0,COUNT(rng)-N,1,N))`

### Explanation

To average the last 5 data values in a range of columns, you can use the AVERAGE function together with the COUNT and OFFSET functions. In the example shown, the formula in F6 is:

`=AVERAGE(OFFSET(D5,0,COUNT(D5:J5)-5,1,5))`

### How this formula works

The OFFSET function can be used to construct dynamic ranges using a starting cell, and given rows, columns, height, and width.

The rows and columns arguments function like “offsets” from the starting reference. The height and width arguments, both optional, determine how many rows and columns the final range includes. We want OFFSET to return a range that begins at the last entry and expands “backwards” so we supply arguments as follows:

reference – the starting reference is D5 – the cell directly to the right of the formula, and the first cell in the range of values we are working with.

rows – we use 0 for the rows argument, because we want to stay in the same row.

columns – for the columns argument, we use the COUNT function to count all values in the range, then subtract 5. This shifts the beginning of the range 5 columns to the left.

height – we use 1 since we want a 1-row range as the final result.

width – we use 5, since we want a final range with 5 columns.

For the formula in C5, OFFSET returns a final range of F5:J5. This goes into the AVERAGE function which returns the average of the 5 values in the range

### Less than 5 values

If there are less than 5 values, the formula will return a circular reference error, since the range will extend back into the cell that contains the formula. To prevent this error, you can adapt the formula as follows:

`=AVERAGE(OFFSET(first,0,COUNT(rng)-MIN(N,COUNT(rng)),1,MIN(N,COUNT(rng))))`

Here we use the MIN function to “catch” situations where there are less than 5 values, and use the actual count when there are.

# Personal Career & Learning Guide for Data Analyst, Data Engineer and Data Scientist

## Applied Machine Learning & Data Science Projects and Coding Recipes for Beginners

A list of FREE programming examples together with eTutorials & eBooks @ SETScholars

# Projects and Coding Recipes, eTutorials and eBooks: The best All-in-One resources for Data Analyst, Data Scientist, Machine Learning Engineer and Software Developer

Topics included: Classification, Clustering, Regression, Forecasting, Algorithms, Data Structures, Data Analytics & Data Science, Deep Learning, Machine Learning, Programming Languages and Software Tools & Packages.
(Discount is valid for limited time only) `Disclaimer: The information and code presented within this recipe/tutorial is only for educational and coaching purposes for beginners and developers. Anyone can practice and apply the recipe/tutorial presented here, but the reader is taking full responsibility for his/her actions. The author (content curator) of this recipe (code / program) has made every effort to ensure the accuracy of the information was correct at time of publication. The author (content curator) does not assume and hereby disclaims any liability to any party for any loss, damage, or disruption caused by errors or omissions, whether such errors or omissions result from accident, negligence, or any other cause. The information presented here could also be found in public knowledge domains.`

# Learn by Coding: v-Tutorials on Applied Machine Learning and Data Science for Beginners

Please do not waste your valuable time by watching videos, rather use end-to-end (Python and R) recipes from Professional Data Scientists to practice coding, and land the most demandable jobs in the fields of Predictive analytics & AI (Machine Learning and Data Science).

The objective is to guide the developers & analysts to “Learn how to Code” for Applied AI using end-to-end coding solutions, and unlock the world of opportunities!

Java tutorials for Beginners – Java final keyword

Excel formula for Beginners – How to Average last 5 values in Excel

Excel formula for Beginners – How to Sum every n rows in Excel