SUMIFS - matching on three criteria

rizzo93

Active Member
Joined
Jan 22, 2015
Messages
303
Office Version
  1. 365
Using SUMIFS, I'm trying to calculate the sum of hours when three criteria are met:
  1. one column matches on a category
  2. another column matches on a team name
  3. and a third column matches on the number of the month
CategoryTeamPeriodHours
MaintenanceAlpha11/21/218
AdministrationBeta11/5/2155
ProjectOmega12/6/2110
AdministrationBeta11/20/2198
SuppliesOrange12/26/215

So if I'm matching on:
  • Month number = 11 (for November)
  • Category = Administration
  • Team = Beta
Then I should get a total of 153 hours.

I can get it to work by matching on category and team, but having difficulty when I include the search on the number of the month:

Excel Formula:
=SUMIFS(q_CombinedData3[Hours],q_CombinedData3[Category],$B8,q_CombinedData3[Team],X$7,q_CombinedData3[Period],MONTH(q_CombinedData3[Period])=11)

Any idea on how I should modify the formula to achieve this?
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi,

This is one way:

Book3.xlsx
ABCD
1MaintenanceAlpha11/21/20218
2AdministrationBeta11/5/202155
3ProjectOmega12/6/202110
4AdministrationBeta11/20/202198
5SuppliesOrange12/26/20215
6
7CriterionResult
8Month11153
9CategoryAdministration
10TeanBeta
Sheet960
Cell Formulas
RangeFormula
C8C8=SUMPRODUCT((A1:A5=B9)*(B1:B5=B10)*(MONTH(C1:C5)=B8)*D1:D5)
 
Upvote 0
Solution
You can't use SUMIFS to check the month of a date. You can use SUMPRODUCT as jtakw showed, if you don't care what year the month is in. If you can, or need, to include a year in the date, you can use SUMIFS like this:

Book2
ABCD
1MaintenanceAlpha11/21/20218
2AdministrationBeta11/5/202155
3ProjectOmega12/6/202110
4AdministrationBeta11/20/202198
5SuppliesOrange12/26/20215
6
7CriterionResult
8Month11/1/2021153
9CategoryAdministration
10TeanBeta
Sheet16
Cell Formulas
RangeFormula
C8C8=SUMIFS(D1:D5,A1:A5,B9,B1:B5,B10,C1:C5,">="&B8,C1:C5,"<="&EOMONTH(B8,0))


Use the 1st of the month in B8, and the formula needs 2 conditions, one for the 1st and one for the last day of the month.
 
Upvote 0
@Eric W has a point, so if the Year is also a requirement, here's a version of SUMPRODUCT to include the year in C9:

Book3.xlsx
ABCD
1MaintenanceAlpha11/21/20218
2AdministrationBeta11/5/202155
3AdministrationBeta11/6/202010
4AdministrationBeta11/20/202198
5SuppliesOrange12/26/20215
6
7CriterionResult
8Month11163
9Year2021153
10CategoryAdministration
11TeanBeta
Sheet960
Cell Formulas
RangeFormula
C8C8=SUMPRODUCT((A1:A5=B10)*(B1:B5=B11)*(MONTH(C1:C5)=B8)*D1:D5)
C9C9=SUMPRODUCT((A1:A5=B10)*(B1:B5=B11)*(MONTH(C1:C5)=B8)*(YEAR(C1:C5)=B9)*D1:D5)
 
Upvote 0
@jtakw and @Eric W, you two are awesome!!!

I made a slight adjustment to the formula you provided to account for the cell referencing the date to get the month:

Excel Formula:
=IFERROR(SUMPRODUCT((q_CombinedData3[Category]=$B8)*(q_CombinedData3[Team]=C$7)*(MONTH(q_CombinedData3[Period])=MONTH($B$3))*q_CombinedData3[Hours]),"-")

Once I did that and made changes to my actual cell references, it all fell into place. I've always found SUMPRODUCT to be confusing, but now that I have some practical application with it, I'm beginning to see the power it offers.

Again, thank you very much!
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,252
Members
452,623
Latest member
Techenthusiast

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