AND statement within SUMIFS?

Yep, this is an 'unofficial' use of SUMPRODUCT - you won't see any examples in the help file or on the MS website of using it in this manner

Date Category Amount
3/5/15 Income $20.00
3/7/15 Phone bill $-50.00
3/12/15 Paycheck $100.00
=SUMPRODUCT((MONTH(A2:A4)=3)*((B2:B4="Income")+(B2:B4="Paycheck"))*(C2:C4))


=SUMPRODUCT({TRUE,TRUE,TRUE}*({TRUE,FALSE,FALSE}+{FALSE,FALSE,TRUE})*{20,-50,100})

When you perform arithmetic Excel will attempt to coerce numbers from the input, and so treats TRUE as 1 and FALSE as 0

=SUMPRODCUT({1,1,1}*({1,0,0}+{0,0,1})*{20,-50,100})

Since there's an extra set of brackets around the Income/Paycheck section, this is the next calculation step, so

=SUMPRODUCT({1,1,1}*{1,0,1}*{20,-50,100})

Now it's straight array multiplication, so

1*1*20=20
1*0*-50=0
1*1*100=100

Which is finally summed to give 120

This is also the reason why the first formula I gave you errors - Excel tries to perform numeric operations on the header row (in Columns A and C) and can't make sense of Month("Date")

It's possible to work around this by testing for valid cell entries within the formula, but the dynamic named ranges are a much better solution, otherwise you end up with an array formula:

=SUMPRODUCT((IFERROR(MONTH(A:A)=3,FALSE))*((B:B="Income")+(B:B="Paycheck"))*(IF(ISNUMBER(C:C),C:C,FALSE)))

This must be input with CTRL+SHIFT+ENTER in the formula bar, not just ENTER, and checks to see if there's an error when using the DATE function on each row in column A, and, if so, returns FALSE, and also checks to see that each row in column C is numeric (again returning FALSE if non-numeric) to allow SUMPRODUCT to do its work

I should have known this was an issue (I've been caught out a few times before), but I only tested with the data, not the header row

/r/excel Thread Parent