*This tutorial will teach you a few easy ways to sum multiple columns in Excel based on a single or multiple criteria.*

Doing a conditional sum in Excel is a piece of cake as long as all the values to be totaled are in one column. Summing multiple columns is a problem because both the SUMIF and SUMIFS functions require the sum range and criteria ranges to be equally sized. Luckily, when there is no straight way to do something, there is always a work-around :)

## Excel Sum If: multiple columns, single criterion

First off, let's get to know exactly what problem we are trying to solve. Suppose you have a table of monthly sales like shown below. Because it was consolidated from a number of regional reports, there are a few records for the same product:

The question is - how do you get a total of sales for a certain item?

The first idea that comes to mind is using a SUMIF formula in its pure form:

`=SUMIF(A2:A10, "apples", C2:E10)`

Unfortunately, this won't work. The reason is that the dimensions of *sum_range* are determined by Excel automatically based on the dimensions of the *range* argument. As our criteria range includes only one column (A2:A10), so does the sum range (C2:C10). The *sum_range* parameter defined in the formula (C2:E10) actually determines only the upper left cell of the range that will be summed. As a result, the above formula will add up the apples sales only in column C. Not what we are looking for, eh?

The simplest working solution that suggests itself is to create a helper column summing the numbers for each individual row, and then use that column for *sum_range*.

So, go ahead and place a SUM formula in F2, then drag it down across as many cells as needed:

`=SUM(C2:E2)`

After that, you can quickly have the job done:

`=SUMIF(A2:A10, I1, F2:F10)`

Where I1 is the item of interest.

In the above formula, *sum_range* is of the same size as *range* (1 column and 9 rows), so it works without a hitch:

If the layout of your worksheet does not have room for any extra columns, then apply one of the following solutions.

### SUMIF multiple columns

The idea is to write a separate SUMIF formula for each of the columns you want to sum, and then add up the results:

Or

A practical implementation looks as follows:

`=SUM(SUMIF(A2:A10,H1,C2:C10), SUMIF(A2:A10,H1,D2:D10), SUMIF(A2:A10,H1,E2:E10))`

Or

`=SUMIF(A2:A10, H1, C2:C10) + SUMIF(A2:A10, H1, D2:D10) + SUMIF(A2:A10, H1, E2:E10)`

You can also "hardcode" the condition in the formula if needed:

`=SUMIF(A2:A10, "Apples", C2:C10) + SUMIF(A2:A10, "Apples", D2:D10) + SUMIF(A2:A10, "Apples", E2:E10)`

This works fine for a reasonable number of columns, but for a large dataset the formula becomes too long and difficult to read. In this case, the below solutions are more appropriate.

### SUM as array formula

Another way to do a sum if in multiple columns based on one criterion is to construct an array formula:

*sum_range*) * (--(

*criteria_range*=

*criteria*)))

For our sample dataset, the formula takes this form:

`=SUM((C2:E10)*(--(A2:A10=H1)))`

Or

`=SUM((C2:E10)*(--(A2:A10="Apples")))`

In Excel 2019 and older, you should press Ctrl + Shift + Enter to complete the formula correctly. In Excel 365 and Excel 2021, this works as a normal formula due to inbuilt support for dynamic arrays.

**How this formula works:**

The core concept is to multiply the elements of these two arrays:

- (C2:E10) - all the values in the sum range. In our case, the array contains 27 elements (3 columns and 9 rows: {250,120,210;155,180,210;130,175,125; …}
- (--(A2:A10=H1)) - compares each value in A2:A10 against the target item in H1. The result is an array of TRUE (the condition is met) and FALSE (the condition is not met) values, which is then converted into an array of 1's and 0's with the help of a double unary operator: {0;1;0;0;1;0;0;1;1}

Please pay attention that the first array is two-dimensional (each column of data is separated by a comma and each row by a semicolon) and the second one is a one-dimensional vertical array (1 column of data, rows are separated by semicolons). When the two arrays are multiplied, all the items of the 2D array in a given row are multiplied by the corresponding element of the 1D array:

As multiplying by zero gives zero, only the numbers for which the criterion is TRUE survive, and the SUM function adds them up:

`=SUM({0,0,0;155,180,210;0,0,0;0,0,0;160,140,170;0,0,0;0,0,0;…})`

To make the formula's logic easier to understand, you can write the first multiplier in this way:

`=SUM((C2:C10 + D2:D10 + E2:E10) * (--(A2:A10=H1)))`

This will produce an array of sums by row (like the helper column does in the very first example), which is then multiplied by an array of 1's and 0's:

`{580;545;430;615;470;750;550;620;570}*{0;1;0;0;1;0;0;1;1}`

The result of multiplication is served to SUM:

`=SUM({0;545;0;0;470;0;0;620;570})`

Don't like using arrays formulas in your sheet? Neither do I. Well, let's go check the next solution :)

### SUMPRODUCT formula

The strategy described in the above example can also be implemented using the SUMPRODUCT function.

*sum_range*) * (

*criteria_range*=

*criteria*))

A real-life formula goes as follows:

`=SUMPRODUCT((C2:E10) * (A2:A10=H1))`

The formula's logic is the same as in the previous example. The beauty of the SUMPRODUCT function is that it supports arrays natively, so it works nicely as a regular formula in all Excel versions.

## Excel Sum If: multiple columns, multiple criteria

The three approaches we utilized to add up multiple columns with one criterion will also work for conditional sum with multiple criteria. The formulas will just become a little more complex.

### SUMIFS + SUMIFS to sum multiple columns

To sum cells that match multiple criteria, you normally use the SUMIFS function. The problem is that, just like its single-criterion counterpart, SUMIFS doesn't support a multi-column sum range. To overcome this, we write a few SUMIFS, one per each column in the sum range:

Or

For example, to sum Grapes sales (H1) in the North region (H2), the formula is:

`=SUMIFS(C2:C10, A2:A10, H1, B2:B10, H2) + SUMIFS(D2:D10, A2:A10, H1, B2:B10, H2) + SUMIFS(E2:E10, A2:A10, H1, B2:B10, H2)`

### Array formula to conditionally sum multiple columns

The SUM formula for multiple criteria is very much like that for a single criterion - you just include additional criteria_range=criteria pair(s):

*sum_range*) * (--(

*criteria_range1*=

*criteria1*)) * (--(

*criteria_range2*=

*criteria2*)))

For instance, to sum sales for the item in H1 and the region in H2, the formula goes as follows:

`=SUM((C2:E10) * (--(A2:A10=H1)) * (--(B2:B10=H2)))`

In Excel 2019 and older, remember to press Ctrl + Shift + Enter to make it an CSE array formula. In dynamic array Excel 365 and 2021, a normal formula will work fine as shown in the screenshot:

### SUMPRODUCT formula with multiple criteria

The easiest way to sum multiple columns based on multiple criteria is the SUMPRODUCT formula:

*sum_range*) * (

*criteria_range1*=

*criteria1*) * (

*criteria_range2*=

*criteria2*))

As you can see, it's very similar to the SUM formula, but does not require any extra manipulations with arrays.

To sum multiple columns with two criteria, the formula is:

`=SUMPRODUCT((C2:E10) * (A2:A10=H1) * (B2:B10=H2))`

These are the 3 ways to sum multiple columns based on one or more conditions in Excel. I thank you for reading and hope to see you on our blog next week!

## Practice workbook for download

Sum if multiple columns - examples (.xlsx file)

## 51 comments

I am trying above formula where data is in one sheet and the formula in other sheet (same workbook) but its not working? while i tried same formula but in same sheet it worked. Is there restriction for using the formula in different sheet than the data sheet?

Hi! There are no such restrictions. I recommend that you read these recommendations: How to SUMIF between two sheets. I hope it’ll be helpful.

Hello!

The SUMIF function works fine between the sheets & I have no issue with that. What i was trying to use the sum array / sumproduct as explained above, but I was getting error. I made some research & found that the error is due to the header (containing alphabet characters) in Value column. It works only when the value column content are numbers only.

Thanks Alexander!

thank you so much for the detailed explanation!

may i ask if this is applicable to summing multiple rows with a single criteria?

How can i match 2 criteria and give result.

example:

Sheet 1

A1 = item code

B1= Location (4 different location)

result=?

Sheet2 is data sheet

A:A= item code

B:B=locations

C:C= value

so if a1 and b1 matches with a:a and b:b then total to be resut.

Hi! If I understand you correctly, to summarize values by multiple criteria, use the SUMIFS function. For more information, please visit: How to use Excel SUMIFS and SUMIF with multiple criteria. I hope it’ll be helpful. If something is still unclear, please feel free to ask.

=(SUMIFS('STK Sheet'!H16:H400,'STK Sheet'!E16:E400,"#4 ACSR",'STK Sheet'!C16:C400,"N"))*(SUMIFS('STK Sheet'!D16:D400,'STK Sheet'!E16:E400,"#4 ACSR",'STK Sheet'!C16:C400,"N"))

I have this formula which multiplies the linear footage of wire(column H) as long as column E shows a specific wire sizer and column C shows N for new wire. I have now created a column D that shows if there are 1, 2, or 3 wires at the location. the above formula does not work because it is taking the sum of the first statement and multiplying it by the sum of the 2nd. I need it to multiply each linear footage(H) by each number of wire(D) then sum all of that together.

H1*D1 + H3*D3 + H7*D7 etc.

any helpful tips?

Hi!

I’m sorry but your description doesn’t give me a complete understanding of your task. To find the sum of the multiplications of numbers, try the SUMPRODUCT function.

I tried this previously and still was unable to make it work the way I needed it to. If column E and C are true I need H and D to be multiplied and added respectively. Maybe I just was not writing my sumproduct correctly

I believe I figured it out.

=SUMPRODUCT(--('STK Sheet'!E16:E400="#4 ACSR"),--('STK Sheet'!C16:C400="N"),('STK Sheet'!H16:H400),('STK Sheet'!D16:D400))

As I am sure you know the "--" makes those columns into numerical values so that it serves the same purpose as the SUMIF criteria

may I ask how to add numbers from different column with #n/a (error) and text in cells and also hidden.

example: How to add this numbers from A1 to H1 ignoring error and text and also hidden column or to add the numbers selected cells ignoring error and text. like A1+B1+E1+F1+H1=300 or A1:H1=300 but errors and text or hidden column are being ignored and the formula can be applied to the rest of the rows by dragging down or copying. thank you so much for your response to this.

A1 B1 E1 F1 H1

1. #N/A WAIVED 100 WAIVED 200

2. 500 WAIVED 120 #N/A 50

Hi!

Please have a look at AGGREGATE function. I hope it’ll be helpful.

Using your example, I want the sum for Apples but only for January and March but then also removing the February.

Is that possible using sumproduct, please?

Please, anyone?

Hi!

Use data for January and March only

=SUMPRODUCT((C2:C10) * (A2:A10=H1) * (B2:B10=H2)) + SUMPRODUCT((E2:E10) * (A2:A10=H1) * (B2:B10=H2))

Thank you so very much!

This can also be done with sumifs, right? Just trying to understand if the results would be indifferent in case we use sumifs for summing non -adjacent columns with single or multiple criteria

Hi! I think in this case you can use the sum of the formulas SUMIFS.

Great work done by you! thanks alot for the details topics covered very briefly. Keep it up and shared the valuable knowledge with community.

Greetings,

Is there a way to use SUMIF, SUMIFS or SUM(IF) searching the criteria in an array?

For example:

=SUMIF(B1:B10,A1:A4,C1:C10)

A B C D E F

1 ABC ABC 10

2 ABC BCD 25

3 XYZ CDE 30

4 DEF DEF 10

5 RST 20

6 DEF 10

7 GHI 15

8 TUV 20

9 BCD 30

10 CDE 10

The result of the example would be = C1+C2+C4+C6+C9+C10

My need for something like this is because in my spreadsheet my array of criteria have 70 values (for instance the 'B1:B4' in the above example is more like 'B1:B70'), and the sumrange have over 1000 lines.

Thank you all in advance!

Hello!

If I understand your task correctly, the following tutorial should help: Excel Advanced Filter - how to create and use.

Hi, I'd like to create a formula that multiplies data in pairs of cells if they're not blank:

The idea is for a cost sheet where there are 6 columns.

The choice is either hours and hourly cost OR number of days and daily rate OR an overall value which would just be multiplied by 1 for the total, then the total column at the end.

I've tried sum/sum if (honestly been working my way around the self-help guides) but I'm clueless and at best I am only able to add 2 columns together whereas I want them multiplied for a total cost.

Hours, Hourly Rate, Days, Daily Rate, Estimated Value, Total

5, 5, blank, blank, blank, total = 5x5

OR

Blank, blank, 10, 10, blank, total =10x10

OR

Blank, blank, blank, blank, 500, total = 500x1 (or just to copy the value entered in the estimated value cell)

Hope this is clear - it's the best I can explain without being able to add a screenshot or excel sheet.

Thanks in advance for any help! :)

Hi!

You can find the answer to your question in this article: How to multiply in Excel using PRODUCT function. I hope it’ll be helpful.

That's worked great, thank you! :)

Is there a chance to sum up the elements in column C in excel if the coordinates in columns A and B are repeated (at least once but maybe more)? So I mean a situation when it will be like this

A B C

0 1 4

0 1 2

0 1 3

0 2 3

....

Hello!

To calculate the sum of two criteria, use the SUMIFS function. If this is not what you wanted, please describe the problem in more detail.

=IF(COUNTIF(I5, "*mlg*"),H5/100000)COUNTIF(I5, "*grm*"),H5/1000))

I am new in excel. Please solved this issue. What is right formula.

Hi!

The following tutorial should help: Excel IF statement for partial text match (wildcard).

=IF(COUNTIF(I5, "*mlg*"),H5/100000, IF(COUNTIF(I5, "*grm*"),H5/1000,""))

Greeting to Ablebits team☺,

I am thankful to you all for such amazing & detailed explanation on excel topics and "also for providing the excel sheet".

But, In some of my previously read articles there are no excel sheets provided for practice.

I would request the team to provide excel example sheet for all the articles. If possible, then please add excel example sheets of previous articles also.

Feedback: -

1) Kindly add Excel practice sheet for each article.

2) Arrange all related topics sequentially.

Hi,

Anyone can help me what formula to use, basically I want to get the sum if date falls under Oct/22, Nov/22, Dec/22 and so on.

Appreciate your help. Thanks!

SKU 10/22/2022 10/29/2022 11/5/2022 11/12/2022 11/19/2022 11/26/2022 12/3/2022 12/10/2022 12/17/2022 12/24/2022 12/31/2022 1/7/2023 1/14/2023 1/21/2023 1/28/2023 2/4/2023 2/11/2023 2/18/2023 2/25/2023 3/4/2023 3/11/2023 3/18/2023

40015048001 0 0 0 0 0 0 100000 0 0 0 200000 0 0 0 0 200000 0

40015048002 0 0 50000 50000 50000 0 0 20000 20000 20000 50000 50000 50000 0 0 0 50000

40015048003 47300 40000 120000 60000 15000 0 0 0 0 0 19084 19084 19084 59358 59358 59358 59358

40015048004 78720 0 0 0 0 0 0 1324 0 0 19084 19084 19084 59358 59358 59358 59358

Hello!

If dates are written in the first column, I recommend reading this guide: How to use Excel SUMIF with dates. This should solve your task.

If the dates are written in the first row, try the SUMPRODUCT formula:

=SUMPRODUCT((B1:R1=DATEVALUE("22.10.2022"))*B2:R5)

I hope it’ll be helpful. If this is not what you wanted, please describe the problem in more detail.

The formula =SUM((C2:E10)*(--(A2:A10=H1))) doesn't work with me neither by pressing ENTER or CTRL+SHIFT+ENTER.

Hi!

The information you provided is not enough to understand your case and give you any advice, sorry.

Hi

How can I sum something like this:

WA11

100

250

WA9

3000

WA11

25

333

Just sum of all WA11, and they are all in same column?

Thanks

Hi!

To calculate the sum by condition, you need an additional column for this condition. Add column B. In cell B1, write

=A1.

In cell B2:

=IF(ISTEXT(A1),A1,IF(ISNUMBER(A2),B1,""))

Copy this formula down along the column. Then apply the SUMIF formula.

Thank you for your help.

Is possible to separate text only if they begin with asterisk * ?

Hi!

You can learn more about using asterisks in this article: Excel wildcard: find and replace, filter, use in formulas.

Feel a bit greedy to give away my personal findings, but "the time has come". Cool kids don't use SUMIF (no offence) while there is more elegant and practical way to aggregate data with the arrays. You described the idea very well, my comment is just for the execution. SUM(IF(A2:A10=H1, C2:E10)) and ctrl + shft+enter gives the same result but in a more intuitive way. And this logic is applicable to any aggregate function such as avg, median or count. Moreover, number of conditions has no limits as well. Lets say we want apples for Jan and Feb: SUM(IF(A2:A10=H1,IF(C1:E1 "Mar", C2:E10))) ctrl + shft+enter. This logic can be also implemented inside index - match, but that's another story...

Using the table above, how would I create the formula to find the total sales of Apples in the East during March, without creating values in the H column?

Thank you so much!

James

Hi!

If you don't want to use cell references in your formula, write those values directly in the formula. I hope I understand your question correctly.

I learned new thing to solve my problem today.

I am trying to sum values in an array if the condition is met. This array width is ever changing based on criteria.

I leave the setting of array width to later part as I did not succeed at the fixed width array too.

My data is set as Table in excel instead of range so that all formula grow together with the table when user add new data.

Here is my formula:

=SUMPRODUCT((RegByModel[[#All],[Jan-15]:[Mar-15]])*(--(RegByModel[[#All],[Model Name]]=Calculation!G81)))

It should sum all values in Table "RegByModel", column [Jan-15] to [Mar-15],

if the criteria in Table "RegByModel", column [Model Name] equals to "Calculation!G81" which is a text value.

If I break the formula into 2 parts, it works fine. But when I combine them into SUMPRODUCT formula, it gave #VALUE! error.

I tried using SUM formula too, same condition.

I use the function "Evaluate Formula" to check, it returns that the first part of the formula is causing error.

The first part of the formula is (RegByModel[[#All],[Jan-15]:[Mar-15]])

If anyone might have an idea on how to solve this, appreciate your input.

Thanks!

Hello!

In the SUMPRODUCT function, all ranges must be the same size. Each of them is a data column. You are trying to multiply two matrix which have different sizes.

Thanks for your quick reply Alexander!

Can I try to understand more which size is not same? Cell height or Width?

If I compare to the example =SUMPRODUCT((C2:E10) * (A2:A10=H1))

(C2:E10) = RegByModel[[#All],[Jan-15]:[Mar-15]] >> There is 3 columns in the example, and 3 columns in my formula. Each column denotes a month.

A2:A10 = RegByModel[[#All],[Model Name]] >> Single column for example and my formula.

H1 = Calculation!G81

Hope to get your further reply. Thanks.

Hi!

You cannot multiply 3 columns of C2:E10 by 1 column of A2:A10. This is mathematics.

Thanks Alexander for your kind help.

Think I need to break this intention into 2 steps.

This is very insightful. Pivot tables can also be used to get the required values. Though we have to update it if anything changes in the data set....Nice analysis, especially with the sumproduct and sum functions.

Please can the SUMIF with conditions return a blank cell?

Hi!

The SUMIF function returns a number. If nothing is found, it returns 0. You can replace zero with an empty value using the IF function.

For example,

=IF(SUMIF(B2:B10, F1, C2:C10) > 0,SUMIF(B2:B10, F1, C2:C10),"")

The writer of this article is the Hero we didn't know we needed.... Until we needed it.

I had a hell of a time Getting the Proper SUMIFS format after i needed to add a second Sum range.

Worked like a champ

=SUMIFS('Monthly Expenses'!D4:D27,'Monthly Expenses'!C4:C27,Values!E1) +SUMIFS('Monthly Savings'!C4:C10,'Monthly Savings'!B4:B10,Values!E1)

Thanks

Thank you, this article is my lifesaver. I spent hours and days trying a find a solution before stumbling upon this. :)

Very nice; very elegant. Thank you!

It's been years since I used Excel, and then only as an amateur.

Just wanted to point out that a possibly-hidden row (above or below) could have cells that each contain a simple SUMIF for their particular column. The grand total would simply sum horizontally across those cells.

I used something like this when I wanted cyclic period information that would expire after 'n' periods. Insert a new column between the titles and the previous period data, and you're off and running.

I've bookmarked this blog for future reference.