+ Reply to Thread
Results 1 to 7 of 7

Cals based on date range

  1. #1
    Registered User
    Join Date
    07-24-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    46

    Cals based on date range

    Date Value 1 Value 2
    1/2/2013 5 66
    1/3/2013 61 57
    1/4/2013 110 1
    1/5/2013 73 63
    1/6/2013 21 29
    1/7/2013 25 64
    1/8/2013 29 21
    1/9/2013 33 47
    1/10/2013 37 59
    1/11/2013 41 28
    1/12/2013 45 63
    1/13/2013 49 20
    1/14/2013 53 24
    1/15/2013 57 44
    1/16/2013 9 93
    1/17/2013 13 63
    1/18/2013 17 77
    1/19/2013 73 29
    1/20/2013 77 4
    1/21/2013 81 42
    1/22/2013 110 11
    1/23/2013 89 15
    1/24/2013 93 38
    1/25/2013 98 73
    1/26/2013 101 23
    1/27/2013 105 37


    Range 1 1/22/2013 through 1/27/2013
    Range 2 1/3/2013 through 1/10/2013

    Value 2 minus Value 1 for Range 1 => (37-105)*100=-6800
    Value 2 minus Value 1 for Range 2 => (59-37)*100=2200

    I couldn't upload the excel file with the above data but I tried to show the calculations that I want to do:

    - basically I want based on the range of dates I have - for example range 1 is 1/22/2013-1/27/2013 - and from the data to get values 1 and 2 from the last date of the range, which in this case is 105 and 37 and to subtract and then multiply by 100 as shown above

    - same logic for the range 2

    Thanks for all your help!

  2. #2
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Cals based on date range

    I'm having trouble figuring out why the first date in the range matters, if you're only linking data to the second date.

    The only reason I can imagine for using the first date in the range would be for summing all of the numbers in between them, but that doesn't seem to be what you need.

  3. #3
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Cals based on date range

    Assuming G1 = 1/27/2013
    Assuming G2 = 1/10/2013

    RANGE 1
    =SUMPRODUCT((A2:A27=G1)*(C2:C27))-SUMPRODUCT((A2:A27=G1)*(B2:B27))

    RANGE 2
    =SUMPRODUCT((A2:A27=G2)*(C2:C27))-SUMPRODUCT((A2:A27=G2)*(B2:B27))

  4. #4
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,938

    Re: Cals based on date range

    Value 2 minus Value 1 for Range 1 => (37-105)*100=-6800
    when I add the values from value1 that fall within those 2 dates - 1/22/13:1/27/13 - I get 596 )110, 89, 93, 98, 101, 105), not 105?
    even if I exclude those 2 dats, I still come up with 381?
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  5. #5
    Registered User
    Join Date
    07-24-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Cals based on date range

    The reason why I want it to refer to a range is that ultimately I have data from 2010 and will be adding data every day. So every week I will show have to show the calculated number for the past week, 1 week before, 2 weeks before, 6 months before and 1 year before.

    So lets say if given the data I have above the past week Monday was 1/22/2013 and Friday was 1/27/2013 then calculate (37-105)*100=-6800 (based of the values in 1/27/2013).

    Then same calculation for 1 week prior would be if Monday was 1/18 and Friday was 1/21 the do (42-81)*100 which is based of the 1/21 values...and so on

    I have a formula in a cell that calculates what date was Fri last week, 1 week ago, 2 weeks ago, 6 months ago, and 1 year ago, and from the corresponding Friday date I calculate what date was Monday so I can get between what dates I need to look to do the calculation.

    I am trying to automate the process as much as I can because it is something I need to do every week so I don't want to enter by hand too much of this but rather to look up the appropriate date range and do the calculation.

    Maybe there is another easier way to set it up that I cant think of. Any suggestions would be very helpful.

    Thanks!

  6. #6
    Registered User
    Join Date
    07-24-2013
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2010
    Posts
    46

    Re: Cals based on date range

    Actually I was just trying out the formula with all the different scenarios and works perfect, and I just need the end date. Thanks daffodil11!

  7. #7
    Forum Expert daffodil11's Avatar
    Join Date
    07-11-2013
    Location
    Phoenixville, PA
    MS-Off Ver
    MS Office 2016
    Posts
    4,465

    Re: Cals based on date range

    Woo woo! Glad I could help.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 0
    Last Post: 05-30-2013, 07:50 PM
  2. [SOLVED] find missing date on every group date list based on range and criteria
    By k1dr0ck in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-25-2013, 01:26 AM
  3. [SOLVED] Date Filter based on Cell Input - single date or range of dates
    By babaloo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-23-2012, 10:32 AM
  4. Calculating values which can be plus or minus
    By moose the goose in forum Excel General
    Replies: 1
    Last Post: 01-27-2012, 03:55 AM
  5. copy date based on date -refer to date range
    By mindpeace in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-03-2006, 08:35 AM

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