Sum multiple columns based on multiple criteria

chicubs

New Member
Joined
Aug 10, 2016
Messages
8
Hello, first time user here! I am trying to calculate total sales for each line item in Sheet 2 from the information given in Sheet 1. For example, Line 1 (Car WK1), should have total sales of 35. I'm having trouble figuring out how to sum multiple columns with the same header by using sumifs and index/match for the item name and week given in Sheet 2. The formula needs to be able to be copied down in Sheet 2.

Sheet 1:
Sales
Item WK1WK1WK2WK2
Car20151015
Boat520510
Plane1015155
Train1510520

<colgroup><col width="64" span="5" style="width:48pt"> </colgroup><tbody>
</tbody>


Sheet 2:
ItemWeekSales
CarWK1???
CarWK2???
Boat WK2???
PlaneWK2???
PlaneWK2???

<colgroup><col width="64" span="3" style="width:48pt"> </colgroup><tbody>
</tbody>
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
I think just the =sumif(top range of sheet 1, cell containing test value on sheet 2(WK1 for example), range of the sales). I pasted what I did below.

A B C D E F G H I
Item WK1 WK1 WK2 WK2 Item Week Sales
Car 20 15 10 15 Car WK1 35
Boat 5 20 5 10 Car WK2 15
Plane 10 15 15 5 Boat WK2 20
Train 15 10 5 20 Plane WK2 =SUMIF($A$1:$E$1,H5, A5:E5)

Edit: formatting got all messed up. Hope the formula makes some sense.
 
Last edited:
Upvote 0
Oops I noticed unless the rows of items are lined up to match (ie Car is always on row 2 of the table on both sheets) cells can sum up on the wrong row. I guess you can put in a bunch of nested if statements, but that could be a huge pain if you have a bunch of skus, weeks of data, or rows. I made this nested if with sumif and it worked:

Code:
=IF($A$2=G2,SUMIF($A$1:$E$1,H2,$A$2:$E$2),IF($A$3=G2,SUMIF($A$1:$E$1,H2,$A$3:$E$3),IF($A$4=G2,SUMIF($A$1:$E$1,H2,$A$4:$E$4))))


I'm sure there's a different method someone else uses that is way cleaner and uses less memory than this way.
 
Upvote 0
A
B
C
D
E
1
Sheet 1:
2
Sales
3
ItemWK1WK1WK2WK2
4
Car
20​
15​
10​
15​
5
Boat
5​
20​
5​
10​
6
Plane
10​
15​
15​
5​
7
Train
15​
10​
5​
20​

<tbody>
</tbody>


A
B
C
1
Sheet 2:
2
ItemWeekSales
3
CarWK1
35​
4
CarWK2
25​
5
BoatWK1
25​
6
BoatWK2
15​
7
PlaneWK1
25​
8
PlaneWK2
20​
9
TrainWK1
25​
10
TrainWK2
25​

<tbody>
</tbody>

Sheet2 c3=SUMPRODUCT((Sheet1!$A$4:$A$7=Sheet2!A3)*(Sheet1!$B$3:$E$3=Sheet2!B3)*(Sheet1!$B$4:$E$7))

copy down
 
Upvote 0
Hi, to piggy back on the question. What if there are multiple criteria under item, and multiple criteria for time?
 
Upvote 0

Forum statistics

Threads
1,215,772
Messages
6,126,810
Members
449,339
Latest member
Cap N

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top