HomeGoogle DocsSpreadsheetMultiple Sum Columns in SUMIF in Google Sheets

Multiple Sum Columns in SUMIF in Google Sheets

Published on

Is it possible to include multiple sum columns in the SUMIF function in Google Sheets?

Usually, it’s not possible. But I have a trick to use more than one sum column in the Sumif function. It will work in array form too.

When you try to include multiple sum columns in Sumif in Google Sheets, you will end up with #N/A error or the sum of the first column only.

Let’s go to one example.

Sample Data:

ABC
1DescriptionJanFeb
2Lemon100100
3Lemon500200
4Avocado400100
5Watermelon500200

The below formula would return 600, i.e., the total of “Lemon” from column B (to learn SUMIF, please check my Google Sheets function guide).

=sumif(A2:A5,"Lemon",B2:C5)

If you use the below one, then you would see the #N/A! error because of the wrong number of arguments in use.

=sumif(A2:A5,"Lemon",B2:B5,C2:C5)

That means, usually, the function SUMIF can only handle a single sum range. There is a clever trick to overcome it.

How to Include Multiple Sum Columns in Sumif Function in Google Sheets

Here is the trick to include more than one sum column in the Sumif function in Google Sheets. As far as I know, it won’t work in Excel.

Syntax: SUMIF(range, criterion, [sum_range])

Steps:

  1. Find the number of columns to sum.
  2. Duplicate the ‘range’ parameter as per the number of sum columns. If there are 2 columns make the duplicate of the range 2 times (Syntax – {range,range,...}).
  3. Then use multiple sum columns as the sum_range.

Example:

As per our above ‘fruit’ data, the range is A2:A5, and the number of columns to add is two. So we must duplicate the range A2:A5 twice. How?

Here it is.

{A2:A5,A2:A5}

Now see the Sumif formula.

=sumif({A2:A5,A2:A5},"Lemon",B2:C5)

This would return 900 as the output.

Yes! The above is the smart trick to include two sum columns in the Sumif function in Google Sheets. This will work in Array Formula (multiple criteria) Sumif too.

Example:

=ArrayFormula(sumif({A2:A5,A2:A5},{"Lemon";"Avocado"},B2:C5))

If there is one more column, i.e., column D, then the formula would be;

=sumif({A2:A5,A2:A5,A2:A5},"Lemon",B2:D5)

If there are several sum columns in the Sumif Sum_range, duplicating the range won’t be practical. In that case, we can simplify the formula as below.

I am rewriting the just above formula with a dynamic range formula.

=ArrayFormula(sumif(if(len(B2:D5)>=0,A2:A5),"Lemon",B2:D5))

range: if(len(B2:D5)>=0,A2:A5)

criterion: “Lemon”

Sum_range: B2:D5

There are several smart workarounds/alternatives too. To learn that, let’s use the sample data on the screenshot below (only the first 3 columns).

different formulas to replace sumif to sum multiple columns

Workarounds that Involve Sumif

On the image, you can see the output of five formulas in D2:H2 and the formula descriptions in D1:H1.

The five formulas sum the columns B and C if the name of the days of the week in column A is “Sun”. That means the criterion is “Sun”.

If you are a basic Google Sheets user and only want to stick with SUMIF, you can follow the below helper column-based solution. It would be easy for you to understand.

It’s easy to use SUMIF with a helper column to include multiple sum columns.

I am starting with the helper column solution first. Then you can see the other five different formulas. Choose the one that you think best suits you.

Sumif with Helper Column

Example:

=sumif(A2:A13,"Sun",D2:D13)

I have used column D, which is the helper column, as the sum_range in SUMIF. Column D contains the total of columns B and C.

Sumif with Multiple SUM columns using helper

I know most of you are not in favor of the helper column use. I myself use helper columns very rarely. So here is a workaround using two Sumif formulas.

By Adding Multiple Sumif Formula Results

I don’t think you need any explanation. In the below example, the first SUMIF formula sums column B. The second one sums column C.

Formula:

=sumif(A2:A13,"Sun",B2:B13)+sumif(A2:A13,"Sun",C2:C13)

Alternative Formulas to SUMIF with Multiple Sum Columns

Here are the most useful alternative formulas in case you want to use multiple sum columns in Sumif in Google Sheets.

SUM and IF Statement Alternative to Sumif with Multiple Sum Columns

Yes! this time I am using the function SUM and IF logical to replace SUMIF. This is one of the widely used formulas in Excel.

=ArrayFormula(
     SUM(
        if(A2:A13="Sun",B2:B13+C2:C13)
     )
)

But in Excel instead of the function ArrayFormula, you should enter the formula using Ctrl+Shift+Enter.

You May Like: Array Formula: How It Differs in Google Sheets and Excel.

There are still even better alternatives to multiple sum column Sumif in Google Sheets. Please read on.

Query Alternative to SUMIF with Multiple Sum Columns in Google Sheets

As I have said many times in the past, Query is one of the best functions in Google Doc Sheets. You can use Query as a substitute for many other functions in Google Sheets.

See how Query replaces SUMIF in this case. It’s one of the elegant solutions.

=sum(
     query(
        A1:C,"Select B+C where A='Sun'"
     )
)

This is one of the best and also my recommend option to use as an alternative to Sumif with multiple sum columns in Google Sheets.

Formula:

=sum(
     filter(B2:C13,A2:A13="Sun")
)

The above formula uses the Filter function to filter columns B and C (sum_range) based on the criteria, i.e., “Sun”, and then sums the columns.

Now here is the final solution.

I know many Google Sheets users are out there who frequently use SUMPRODUCT to replace SUMIF/SUMIFS.

The reason, SUMPRODUCT can make your formulas shorter, smarter, and easy to read. See this one!

Formula:

=SUMPRODUCT(B2:C*(A2:A="Sun"))

I have provided a couple of formula options above for you to use when you want to use multiple sum columns in Sumif in Google Sheets.

Which one do you prefer? Like to hear your views in the comments below. Enjoy!

Related Reading:

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.

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

SORT and SORTBY – Excel Vs Google Sheets

While Excel offers the SORT and SORTBY functions for sorting a table, Google Sheets...

Get Top N Values Using Excel’s FILTER Function

When using the FILTER function in Excel to extract the top N values, it's...

More like this

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

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...

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.