MS Office Forum / Excel / General Excel Questions / March 2008
Sum by date
|
|
Thread rating:  |
hmsawyer - 17 Mar 2008 15:41 GMT In column B, I am trying to add up the values in columns E, H, K, etc (every third column), but ONLY if the corresponding date in columns C (for E), F (for H), I (for K), etc (every third column) is within 6 months from TODAY. I can move the data around if the values need to be next to the corresponding dates, but that will move around some list validations I already have set up, so I'm trying to avoid it if possible.
I think it is a sum if, but I can't get it to work. Any help is appreciated. Thank you so much!
hmsawyer - 17 Mar 2008 17:16 GMT I found this one in an old post and it is almost what I need:
=SUMIF(A1:A100,">=" & DATE(YEAR(TODAY())-1,MONTH(TODAY()),1),B1:B100)
However, I need to use a rolling 6 months and this formula is using an entire year. How would I change it? Thanks!
> In column B, I am trying to add up the values in columns E, H, K, etc (every > third column), but ONLY if the corresponding date in columns C (for E), F [quoted text clipped - 5 lines] > I think it is a sum if, but I can't get it to work. Any help is > appreciated. Thank you so much! David Biddulph - 17 Mar 2008 17:48 GMT Have you tried =SUMIF(A1:A100,">=" & DATE(YEAR(TODAY()),MONTH(TODAY())-6,1),B1:B100) ?
 Signature David Biddulph
>I found this one in an old post and it is almost what I need: > [quoted text clipped - 16 lines] >> I think it is a sum if, but I can't get it to work. Any help is >> appreciated. Thank you so much! David Biddulph - 17 Mar 2008 17:55 GMT I notice, however, that the formula you quoted wasn't "using an entire year", but was going back to the first of the month, so from 17 March 2008 would go to 1 March 2007. My formula does the same for 6 months so would go to 1 September 2007. If you actually want to go back 6 months from today (to 17 September 2007), then change the formula to =SUMIF(A1:A100,">=" & DATE(YEAR(TODAY()),MONTH(TODAY())-6,DAY(TODAY())),B1:B100)
 Signature David Biddulph
> Have you tried > =SUMIF(A1:A100,">=" & DATE(YEAR(TODAY()),MONTH(TODAY())-6,1),B1:B100) ? [quoted text clipped - 19 lines] >>> I think it is a sum if, but I can't get it to work. Any help is >>> appreciated. Thank you so much! hmsawyer - 17 Mar 2008 18:08 GMT I guess we were typing at the same time.
That worked! Thanks so much for the help!
> I notice, however, that the formula you quoted wasn't "using an entire > year", but was going back to the first of the month, so from 17 March 2008 [quoted text clipped - 27 lines] > >>> I think it is a sum if, but I can't get it to work. Any help is > >>> appreciated. Thank you so much! hmsawyer - 17 Mar 2008 18:04 GMT That is almost it, but it is calcuating by the month and not the day. For instance, 8/31/07 is not returning a value (as it shouldn't--it's over 6 months from today), but 9/1/07 is---the oldest date that should return a value today would be 9/19/07--exactly 6 months ago.
Thanks for the help!
> Have you tried > =SUMIF(A1:A100,">=" & DATE(YEAR(TODAY()),MONTH(TODAY())-6,1),B1:B100) ? [quoted text clipped - 18 lines] > >> I think it is a sum if, but I can't get it to work. Any help is > >> appreciated. Thank you so much! Tom Hutchins - 17 Mar 2008 17:57 GMT I'm not sure if you only want to check for dates up to 6 months in the future, or in the past also. Either way, to calculate the date 6 months from now, paste this into an out-of-the-way cell:
=DATE(IF(MONTH(NOW())>6,YEAR(NOW())+1,YEAR(NOW())),IF(MONTH(NOW())>6,MONTH(NOW())-6,MONTH(NOW())+6),DAY(NOW()))
If you only want to check for future dates, start with a formula like this in column B:
=SUMPRODUCT(--(C5:C1000<=$A$1),E5:E1000)
In this example, the date 6 months from today is found in cell AA1. Add as many copies of the SUMPRODUCT formula as necessary to itself, editing the column references each time. For example:
=SUMPRODUCT(--(C5:C1000<=$A$1),E5:E1000)+SUMPRODUCT(--(F5:F1000<=$A$1),H5:H1000)
Empty cells in the date columns won't cause problems, but text that Excel can't interpret as a date will. Therefore, the format of your dates might mean we need to adjust the formula.
If you want to look for past dates within 6 months as well as future dates, then you can use something like this:
=SUMPRODUCT(--(ABS(C5:C1000-NOW())<=ABS($A$1-NOW())),E5:E1000)
Hope this helps,
Hutch
> In column B, I am trying to add up the values in columns E, H, K, etc (every > third column), but ONLY if the corresponding date in columns C (for E), F [quoted text clipped - 5 lines] > I think it is a sum if, but I can't get it to work. Any help is > appreciated. Thank you so much!
|
|
|