+ Reply to Thread
Results 1 to 11 of 11

lookup values by date

  1. #1
    Registered User
    Join Date
    11-28-2012
    Location
    bozeman, MT
    MS-Off Ver
    Excel 2003
    Posts
    3

    lookup values by date

    I have a spreadsheet I'm trying to figure out the formula for.....

    The spreadsheet include an account#, name of a trade show, the date of the trade show, and then every single month for the past 2 years or so. Under each month it tells me how many orders that particular account number has placed for that month. I would like to know see how many orders each account placed 3 months before show date, 3 months after show date, 6 months before show date, 6 months after show date, 12 months before show date, 12 months after show date.

    For example the Show ASI Chicago 2009 took place 07/01/2009. See how many orders the account number ALLE43077 placed 3 months before 07/01/2009 (April 2009, May 2009 and June 2009) total into one cell, 3 months after 07/01/2009 (August 2009, September 2009 and October 2009) totaled into one cell
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: lookup values by date

    Hi,

    See attached.

    I've added formulae for the 3 months before and after. I'll leave you to replicate the formula for the +/- 6 months & +/- 12 months.

    You need to decide whether the C column dates and the prior and succeeding cut off dates are inclusive or exclusive.
    Attached Files Attached Files
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    11-28-2012
    Location
    bozeman, MT
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: lookup values by date

    Thanks Richard! When I copy the formula down in my complete spreadsheet it doesn't work. I receive #Name? Also when I extend the formula to the right for +/- 6 months +/- 12 months, I thought I could just copy the formula over and change the -3s to -6s and -12s and keep everything else the same but its giving me #NAME? as a result. What am I doing wrong?

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: lookup values by date

    Hi,

    You can't just copy the formula over since if you look the reference to column C is not absolute. Maybe it should have been but that's life! Similarly the reference to JD2:BD2 should have been $JD2:$BD2.

    And yes you'll need to change the -3 & 2 in the EOMONTH part to -6 +5, and -12 +11

  5. #5
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: lookup values by date

    Hi ShaylaMc,

    Richard's formula works really well in my computer, but then I noticed that you have an older version of Excel. SUMIFS formula only working in 2007+, not in 2003 version.

    Try this formula instead...
    =SUMPRODUCT(($J2:$BD2)*($J$1:$BD$1>=DATE(YEAR(EOMONTH($C2,-3)),MONTH(EOMONTH($C2,-3)),DAY($C2)))*($J$1:$BD$1<$C2))

  6. #6
    Registered User
    Join Date
    11-28-2012
    Location
    bozeman, MT
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: lookup values by date

    Thanks for both helping. The new formula djapigo provided does not work. I do have excel 2003. I have attached an updated spreadsheet showing that I'm receiving #NAME?

    Thanks again for the help!
    Attached Files Attached Files

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: lookup values by date

    Hi,

    The EOMONTH(() function is also new in 2007 and not present in Excel 2003. If you can live with a definition of 6 months being 183 days then in F2

    Formula: copy to clipboard
    Please Login or Register  to view this content.

    and for G2
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Similar for the 3 month and 12 month formulae. If the 6 month needs to work with calendar months then a more complicated function will be necessary. Note that using 183 days like this will not always give you the same result as using calendar months since depending on the month span, 183 may not co-incide with 6 months before or after.

  8. #8
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: lookup values by date

    Sorry, try this...

    D2: =SUMPRODUCT(($J2:$BD2)*($J$1:$BD$1>=DATE(YEAR($C2),MONTH($C2)-3,DAY($C2)))*($J$1:$BD$1<$C2))

    E2: =SUMPRODUCT(($J2:$BD2)*($J$1:$BD$1>=DATE(YEAR($C2),MONTH($C2)+3,DAY($C2)))*($J$1:$BD$1<$C2))

  9. #9
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: lookup values by date

    Quote Originally Posted by djapigo View Post
    Sorry, try this...

    D2: =SUMPRODUCT(($J2:$BD2)*($J$1:$BD$1>=DATE(YEAR($C2),MONTH($C2)-3,DAY($C2)))*($J$1:$BD$1<$C2))
    Just a thought, but isn't one of the difficulties with this that if the test date is in the Jan-March period, the function MONTH(C2)-3 will result in zero or minus. That was one of my reasons for thinking that the pragmatic approach of using 183 days is simpler.

  10. #10
    Valued Forum Contributor
    Join Date
    09-10-2012
    Location
    Los Angeles, CA
    MS-Off Ver
    Excel 2010
    Posts
    929

    Re: lookup values by date

    Hi Richard,

    I wasn't sure either, but I took a shot and it seems the DATE function can read negative months and just remove it from years... go figure...

  11. #11
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: lookup values by date

    Quote Originally Posted by djapigo View Post
    Hi Richard,

    I wasn't sure either, but I took a shot and it seems the DATE function can read negative months and just remove it from years... go figure...
    Mmm. Interesting. Must admit didn't test that proposition, mainly because I've always had in my mind that a deduction of a negative month couldn't wind back the year as well.

    ....you live and learn as they say.


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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