HomeGoogle DocsSpreadsheetHow to Sum Each Row in Google Sheets

How to Sum Each Row in Google Sheets

Published on

This post is about creating a total column in Google Sheets using an array formula.

For that purpose, you can depend on the functions MMULT, Query, or the ‘+’ Sign. All these can sum each row in a table in Google Sheets.

Also, there is a new possibility of using one of the Lambda functions. So creating a column that contains the total in each row is easy.

To sum values, as you may already know, you can use the SUM function. 

It takes an array but won’t return an array. I mean, it won’t give you an expanding array result.

So, to sum each row in Google Sheets, you need to look for other functions, a Lambda, or function combinations, as mentioned above.

I am using function combinations in this tutorial. So I’m unable to explain every function involved in the combo. So please use my Google Sheets Functions Guide for reference.

To sum each row ‘manually’ in Google Sheets, you can use the below Sum formula in cell I2 and drag it down (see the GIF below).

=sum(C2:H2)
Sum each row manually in Google Sheets

It’s not an array formula.

You can’t include the whole rows in a single formula this way.

That’s why I entered the formula in a single cell and copied it down.

Let me start with the best solution (array formula) to add a column with the total in each row in Google Sheets.

The Ultimate Solution to Sum Each Row in Google Sheets

We can take the above data as our example. I want to sum the columns C to H in each row.

Steps:

Empty column I, and in cell I1, enter the below MMULT formula. It is a flexible solution to sum each row in Google Sheets. It covers the range C2:H.

={"Total";arrayformula(if(len(A2:A),mmult(n(C2:H),transpose(sign(column(C:H)))),))}

You can insert columns between C to H, and the above MMULT formula would include the values in the newly inserted columns in the total.

You can adapt this formula for your data range.

Inside the MMULT, you can include your columns to sum. But take care of the formula if(len(A2:A),.

I have some text values in A2:A. I have used the Len function to limit the MMULT output to the last row containing a value in A2:A.

The above Len formula is equal to the below logical test. So you can use either of the ones.

if(A2:A<>"",

See the same MMULT in a new data range to understand it better. This time I am only using two-column data.

Sum each row in Google Sheets using MMULT array formula

MMULT is not the only formula to sum values in multiple columns in each row.

Here are the alternative solutions, but they are not flexible except for the Lambda given at the end.

When you insert any new column between the range/array, they won’t adjust the range to sum (C2:H in the first example and B2:C in the second).

But it does not apply to the Lambda solution.

How to Add Total Column Using Query in Google Sheets

You can very quickly add a total column to a range using Query.

=Query(A1:H,"Select C+D+E+F+G+H label C+D+E+F+G+H'Total'",1)

I am using the same sample data which you have seen in the first example here.

This Query formula in cell I1 will place a total column. Now let me show you why this formula is not flexible.

See, I have inserted a new column, and our range to sum is now C2:I.

Total column using Query and flexibility issue

If you try MMULT and Query, you can understand that MMULT returns the correct total. The Query will fail in this case.

But Query has one advantage. If you want, you can get multiple-column output.

=Query(A1:H,"Select A,C+D+E+F+G+H label C+D+E+F+G+H'Total'",1)

This formula will return a two-column output in which the first column will be the “Item Desc” and the second one the “Total”.

You can specify the extra column that you want to include in the Select clause in Query.

Get an extra column with the total column

That doesn’t mean you can not include an additional column in MMULT. That is possible, but simple to do using Query.

Sum Each Row Using the ‘+’ Sign in Google Sheets

Here is one more array formula to get the total in each row. This formula is also for cell I1. It will also expand down the column.

={"Total";ArrayFormula(if(len(A2:A),C2:C+D2:D+E2:E+F2:F+G2:G+H2:H,))}

When you insert a new column, you must edit this formula to include it.

That means this follows the same flexibility issue we faced in Query.

Sum Function with Byrow – Recommended

The regular Sum formula may not spill its result. But by using BYROW, we can make it spill down. Here is how.

={"total";byrow(C2:H,lambda(r,if(counta(r)=0,,sum(r))))}

This formula is as per the sample data in the first screenshot (example). So it must be keyed in cell I1.

You can see the presence of the COUNTA function in the BYROW Lambda formula.

It’s to omit sum results in rows, where there is no value in count due to blank.

There is one more dynamic formula to sum each row in Google Sheets.

That is using a database function which I have included in the first tutorial below.

Additional Resources:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

Excel Word Count: Beyond SUBSTITUTE

You might want to count the number of words in a cell in Excel...

More like this

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

Google Sheets Bar and Column Chart with Target Coloring

To color each data point in the column or bar chart according to the...

Analyzing Column A Between Non-Adjacent Values in Column B: Google Sheets

This tutorial addresses a common scenario encountered in Google Sheets: how to sum, average,...

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.