Sumif on match AND date criteria?

Ajw43022

New Member
Joined
Aug 16, 2009
Messages
28
I need to sum values in a column if both serial numbers match AND if the match's date is less than 5 days ago.

I can do both individually:

=SUMIF('All2'!$AH$3:$AH$1000,F4,'All2'!$AI$3:$AI$1000)

=SUMIF('All2'!$AJ$3:$AJ$1095,"<="&NOW()-5,'All2'!$AI$3:$AI$1095)

But I can't for the life of me figure out how to combine the two. Any help would be very appreciated!
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I need to sum values in a column if both serial numbers match AND if the match's date is less than 5 days ago.

I can do both individually:

=SUMIF('All2'!$AH$3:$AH$1000,F4,'All2'!$AI$3:$AI$1000)

=SUMIF('All2'!$AJ$3:$AJ$1095,"<="&NOW()-5,'All2'!$AI$3:$AI$1095)

But I can't for the life of me figure out how to combine the two. Any help would be very appreciated!

Hi,

How about

Code:
=SUMPRODUCT(--('All2'!$AH$3:$AH$1000=F4),--('All2'!$AJ$3:$AJ$1000<=Now()-5),'All2'!$AI$3:$AI$1000)

<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
Thanks for your response!

I'm getting an #N/A when I apply that unfortunately though. No idea why. The two equations separately work like a charm, and yours seems like a logical combination of the two, but somehow there's a problem.

Any ideas?

thank you.
 
Upvote 0
Using SUMPRODUCT in this manner requires ranges to be the same size.

What is the data in 'All2'!$AH$3:$AH$1000? Text, Numbers...?

Try

Code:
=SUMPRODUCT(('All2'!$AH$3:$AH$1000=F4)*('All2'!$AJ$3:$AJ$1000<=Now()-5)*('All2'!$AI$3:$AI$1000))

OR

Code:
=SUM(IF('All2'!$AH$3:$AH$1000=F4,IF('All2'!$AJ$3:$AJ$1000<=Now()-5,'All2'!$AI$3:$AI$1000,0)))
Confirmed with Control+Shift+Enter and not just Enter.

Also, I'm not sure if it'll help, but try TODAY()-5 instead of NOW()-5

<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0
Found the problem! Rows 800+ for AH were #VALUE!. This didn't affect the formulas individually, but they messed up the SUMPRODUCT. I corrected that, and now your original formula works wonderfully.

Thank you so much, and I apologize for the screw-up on my end.
 
Upvote 0
If you are in Excel 2007, you can use the SUMIFS formula. It will sum one range if any multiple number of criteria are matched.
 
Upvote 0
Found the problem! Rows 800+ for AH were #VALUE!. This didn't affect the formulas individually, but they messed up the SUMPRODUCT. I corrected that, and now your original formula works wonderfully.

Thank you so much, and I apologize for the screw-up on my end.

You're welcome. I'm glad you were able to resolve the problem.
<input id="gwProxy" type="hidden"><!--Session data--><input *******="jsCall();" id="jsProxy" type="hidden">
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

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