Sumif Dates excluding some

mickeystanford_alumni

Board Regular
Joined
May 11, 2022
Messages
129
Office Version
  1. 2021
Platform
  1. Windows
  2. MacOS
Hi everyone,

I am trying to sum various columns with values where the first column is a date column. However, what I want is to exclude certain value linked to certain dates. E.g.

A1 B1 C1
01/01/1990 50 50
02/01/1990 60 100
03/01/1990 70 10
04/01/1990 80 50
05/01/1990 90 70

I want to sum B1 and C1, but excluding for example 03/01/1990.

For simplication this is the example, however, there are like 20 dates I would like to exclude. So not sure if making an index in a way where I could choose all dates I want to exclude would make it easier. As if in the formula I have to choose one by one is a very very long formula.

Thank you.

M
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
The first two methods that come to mind. It won't make much difference with the example but you might find that one calculates faster than the other with a large data set.
Book1
ABCDE
1Exclude
201/01/1990505003/01/1990
302/01/19906010004/01/1990
403/01/19907010
504/01/19908050
605/01/19909070420
7420
Sheet4
Cell Formulas
RangeFormula
E6E6=SUM(FILTER(B2:C6,ISNA(MATCH(A2:A6,E2:E3,0)),0))
E7E7=SUM(B2:C6,-SUMIF(A2:A6,E2:E3,B2:B6),-SUMIF(A2:A6,E2:E3,C2:C6))
 
Upvote 0
Solution
Let say you have list of will be excluded dates on column D. D1: 2.01.1990, D2: 3.01.1990. B6 is going to give you 220 excluding these dates.
Excel Formula:
=SUM(B1:B5)-SUMPRODUCT(SUMIF($A1:$A5,$D1:$D2,B1:B5))
 
Last edited by a moderator:
Upvote 0
Hi both, thank you so much. Both methods perfectly work.
One more question is, what about if I would like to do the opposite, from the A1 column, only add the excluding ones.
It could possibly be done with =SUM(B2:C6)-=SUM(FILTER(B2:C6,ISNA(MATCH(A2:A6,E2:E3,0)),0)).
But maybe there is other way with the filter function...just wondering.
Thanks a lot again
 
Upvote 0
For my solution it is:

Excel Formula:
=SUMPRODUCT(SUMIF($A1:$A5,$D1:$D2,B1:B5))
 
Upvote 0
Hello, could I please ask something else?
If I have the dates in the format dd/mm/yyyy hh:mm, and I would like to just sum the value between 10:00-11:00?
Let say in the dataset by Jason:
01/01/1990 9:00 10
01/01/1990 10:00 20
01/01/1990 11:00 10
01/01/1990 12:00 15

Therefore, I would like to get the values between 10:00 and 11:00, which is 30. Again, in a way which I scale this to many dates, although the time constraint will be always the same.
Thank you so much for your patience and aid.
 
Upvote 0
Would it just be one column of values this time or still 2 columns as with the original question?

With 1 column I would use a variation of the sumif method but with more i think that filtering using mod would be more efficient.
 
Upvote 0
Hey Jason, thank you for your response.
It would be 2 columns still. Same as original question but with date+time as I previously commented.
Thank you for your help :)
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

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