5
votes

I am trying to get a SUMIFS formula to check a column of dates and sum only the values that correspond to the matching year and month of the criterion date. I would also like this SUMIFS to include a name criterion along with the date. i.e.

Cell A1: =SUMIFS('Sheet1'!O:O, 'Sheet1'!D:D, 'Sheet2'!DATE(B2), 'Sheet1'!E:E, "Name")

sheet1 column O is where the sum values are stored
sheet1 column D is where the date values are stored
sheet2 cell B2 is where the date comparison criterion is stored
sheet1 column E is where the names are stored
"Name" is the name criterion that I want for sum selection

Any insight will be most appreciated!

2

2 Answers

4
votes

You can use SUMIFS if you create a start and end date for your dates, i.e. with this version

=SUMIFS('Sheet1'!O:O,'Sheet1'!D:D, ">="&EOMONTH('Sheet2'!B2,-1)+1, 'Sheet1'!D:D, "<"&EOMONTH('Sheet2'!B2,0)+1, 'Sheet1'!E:E, "Name")

EOMONTH is used to get the start and end dates of the relevant month then your SUMIFS sums the correct values based on your other criteria.

If B2 is guaranteed to be the first of the month you can omit the first EOMONTH function

0
votes

Solution with SUMPRODUCT

I find it simpler to use SUMPRODUCT in situations like this.

For no header row you can simple use:

=SUMPRODUCT((MONTH(Sheet1!D:D)=MONTH(Sheet2!$B$2))*(YEAR(Sheet1!D:D)=YEAR(Sheet2!$B$2))*(Sheet1!E:E="Name"),Sheet1!O:O)

Just replace "Name" with what you want.

If you have a header row (or if the column contains any values that are not valid dates) you need to use an array formula within SUMPRODUCT:

=SUMPRODUCT((IF(ISERROR(MONTH(Sheet1!D:D)),Sheet1!D:D,MONTH(Sheet1!D:D))=MONTH(Sheet2!$B$2))*(IF(ISERROR(YEAR(Sheet1!D:D)),Sheet1!D:D,YEAR(Sheet1!D:D))=YEAR(Sheet2!$B$2))*(Sheet1!E:E="Name"),Sheet1!O:O)

(Array formulas are entered using ctrl + shft + enter)