0

I have a range of dates in a worksheet that run across an entire row in format mm/dd/yyyy. As part of a SUMIF function I'd like to add up all the "points" that fall within a month/year combination (which would be specified via a cell reference). Any thoughts on how to do this? Should I instead try an If statement nested within SUM?

3
  • just book end, you want all the dates that are greater than or equal to the 1st of the month/year and less than the last day of the month/year. Commented Jul 20, 2021 at 19:26
  • Are you able to make a criteria row or column which is the date range (e.g. monthly or weekly). SUMIF uses a criteria so this might possibly work.
    – anon
    Commented Jul 20, 2021 at 19:56
  • SUMPRODUCT is also a suggestion, do you have a sample?
    – Lee
    Commented Jul 22, 2021 at 8:16

1 Answer 1

3

As @Scott Craner said, you can bookend the first and last dates of the month and then use a SUMIFS to add up all the "points".

Here's a simple example with a value of 1 in column B for every day in a month. Enter any date D3, and the formula in E3 will add up all the values in column B if the date in column A is between the first and last days of the month.

=SUMIFS(B:B,A:A,">="&DATE(YEAR(D3),MONTH(D3),1),A:A,"<="&EOMONTH(D3,0))

If you're using a text field in D3 instead of a date, you'd have to add DATEVALUE() to the formula to convert it to a date before extracting the first and last days of the month.

enter image description here

And here it is with the dates transposed into columns instead of rows. Same idea, but maybe harder to see in the screenshot.

enter image description here

4
  • This works exactly how I'd like it! Somewhat of a tangential question: can a SUMIF use an array as its first argument?
    – fruityflex
    Commented Jul 20, 2021 at 21:03
  • 1
    @fruityflex - Regrettably, no.
    – will
    Commented Jul 20, 2021 at 21:15
  • I believe in my particular case, since the summation is all values within an array meeting certain criteria, I'd need to do a SUMProduct instead. How would the same argument be written there?
    – fruityflex
    Commented Jul 20, 2021 at 21:17
  • =SUMPRODUCT(B:B,--(MONTH(A:A)=MONTH(D3)),--(YEAR(A:A)=YEAR(D3)))
    – will
    Commented Jul 21, 2021 at 13:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .