+ Reply to Thread
Results 1 to 8 of 8

Adding values within date range

  1. #1
    Registered User
    Join Date
    04-16-2006
    Posts
    11

    Question Adding values within date range

    Hi,

    I have a table which diplays dates in the first column, then values corresponding to the dates in the third colum. It looks like this:

    12/23/2005 Bread $3.25
    12/26/2005 Milk $2.50
    01/22/2006 Jam $4.00

    What I'd like to do is to add the totals of the values listed in the third column according to the dates. For example, the formula should only add money spent within the year 2005.

    How can I do this?

    Thanks!

  2. #2
    Forum Contributor
    Join Date
    10-14-2004
    Location
    San Diego, CA
    Posts
    213
    Hi robotfighter:

    =SUMPRODUCT(--(YEAR($A$1:$A$20)=2005),($C$1:$C$20))

    Matt

  3. #3
    Registered User
    Join Date
    04-16-2006
    Posts
    11
    Thanks. Unfortunately, I was just informed that the values that need to be summed are actually within a specific date range (e.g., between 10/28/1998 and 4/12/1999). Is this possible?

  4. #4
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    Have you tried a pivot table. This approach is much more flexible for this type of thing

    http://www.cpearson.com/excel/pivots.htm

    Matt

  5. #5
    Registered User
    Join Date
    04-16-2006
    Posts
    11
    I did, but it did not accomplish what we were looking to do.

    The person requesting this formula would like to be able to specify a date, at which point the formula will sum all amounts for the previous year leading up to the date (365 days, not just the previous calendar year). For example, when specifying the date 6/7/2000, all amounts from 6/8/1999 through 6/7/2000 would be calculated).

    I found a formula involving sumproduct which came close, but it could not automatically sum up the previous year to the specified date. Below is the actual formula I have been using (which I found on another forum) - the bolded portions are the cells containing the starting date followed by the ending date - again, I would like the formula to automatically determine the starting date in accordance to the ending date):

    =SUMPRODUCT((B11:B218>=B11)*(B11:B218<=B95)*(E11:E218))

    Thanks for all your help!
    Last edited by robotfighter; 10-13-2006 at 07:24 PM.

  6. #6
    Valued Forum Contributor
    Join Date
    06-16-2006
    Location
    Sydney, Australia
    MS-Off Ver
    2013 64bit
    Posts
    1,394
    I have spent the last 30 mins trying to work this out using array formulas, but can't get it to work. I suggest you do this in a couple of steps. Create a new column that creates returns the value to add if the condition is met, or 0 if it is not met.

    something like =IF(AND(A1>DATE(2005,12,22),A1<DATE(2005,12,28)),C1,0)

    Then simply sum this column

    Matt

  7. #7
    Registered User
    Join Date
    04-16-2006
    Posts
    11
    I'm sorry... I'm not sure how I would apply this to what I am doing... All cells will be added in individual groups, not only ones that meet a certain criteria.

  8. #8
    Forum Contributor
    Join Date
    01-23-2006
    Posts
    194
    You could try the following...
    create a small table in another worksheet which contains a date in column A and some relevant grouping value in column B.
    Add a helper column which in the data sheet which does a vlookup on the date against the values in the other worksheet then you get absolute control of the grouping. Then create a pivot table using tha labels in the helper column to group by.

    regards

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1