Excel formula for Beginners – How to Sum last n columns in Excel

 

(Excel examples for Beginners)

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

 

Excel formula for Beginners – How to Sum last n columns in Excel

Generic formula

=SUM(INDEX(data,0,COLUMNS(data)-(n-1)):INDEX(data,0,COLUMNS(data)))

Explanation

To sum the last n columns in a table of data (i.e. last 3 columns, last 4 columns, etc.) you can use a formula based on the INDEX function. In the example shown, the formula in K5:

=SUM(INDEX(data,0,COLUMNS(data)-(K4-1)):
INDEX(data,0,COLUMNS(data)))

where “data” is the named range C5:H8

How this formula works

The key to understanding this formula is to realize that the INDEX function can be used to return a reference to entire rows and entire columns.

To generate a reference to the “last n columns” in a table, we build a reference in two parts, joined by the range operator. To get a reference to the left column, we use:

INDEX(data,0,COLUMNS(data)-(K4-1))

Since data contains 6 columns, and K4 contains 3, this simplifies to:

INDEX(data,0,4) // all of column 4

To get a reference to the right column in the range, we use:

INDEX(data,0,COLUMNS(data))

Which returns a reference to column 6 of the named range “data”, since the COLUMN function returns 6:

INDEX(data,0,6) // all of column 6

Together, the two INDEX functions return a reference to columns 4 through 6 in the data (i.e. F5:H8), which resolve to an array of values inside the SUM function:

SUM({15,14,10;9,12,12;7,9,9;12,13,13})

The SUM function then calculates and returns the sum, 135.

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

95% Discount on “Projects & Recipes, tutorials, ebooks”

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!

 

C++ for Beginners: C++ Call by Reference: Using pointers

Excel formula for Beginners – How to Calculate running total in Excel

Beginners Guide to SQL – SQL CREATE INDEX Statement