+ Reply to Thread
Results 1 to 4 of 4

Nested What If statement using date ranges

  1. #1
    Registered User
    Join Date
    01-08-2012
    Location
    USA
    MS-Off Ver
    Excel 2007
    Posts
    3

    Nested What If statement using date ranges

    Hello,

    I am trying to create a nested what if statement in excel using multiple date ranges. For example:

    If Cell X > 12/2/2009 but less than 12/31/2011 return 0-3

    If Cell X > 12/2/2006 but less than 12/2/2009 return 3-5

    If Cell X > 12/2/2001 but less than 12/2/2006 return 5-10

    If Cell X < 12/2/2001 return over 10

    The what if statement I created rerutrns the same answer regardless what is in Cell X
    =IF(J31>="12/2/2009"&J31<"12/31/2011","0-3",IF(J31>="12/2/2006"&J31<"12/2/2009","",IF(J31>="12/2/2001"&J31<"12/2/2006","5-10",IF(J31<="12/2/2001","over 10"))))

    Please help

  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: Nested What If statement using date ranges

    Hi Glenn and welcome to the forum,

    There seem to be a couple of things wrong.

    1. You appear to be using literals (i.e. text strings) for your dates in the formula, whereas I suspect column J probably contains proper date numbers.
    2. In any case you are not using the correct AND() syntax condition in your formula. The '&' symbol is not the same as the logical 'AND' condition.

    But more importantly you would be better off using a VLOOKUP table rather than complicating your requirement with an IF formula. Build yourself a two column list with dates in the first column and the values yo require '0-3', '3-5', '5-10', 'over 10' in the second column and use the VLOOKUP to lookup a column J date in the second column of the list.

    Just another observation which may be irrelevant but annoys the statistician in me. Should not the items returned be '0-3, 'over 3-5', 'over 5-10', etc.? Values like 3,5,10 seem to fit into two categories.
    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
    Forum Guru
    Join Date
    05-24-2011
    Location
    India
    MS-Off Ver
    Office 2021
    Posts
    2,237

    Re: Nested What If statement using date ranges

    Hello Glenn,

    Make 2 column table. First column enter starting level dates. say in A1:B5

    Please Login or Register  to view this content.
    Then use like,

    =LOOKUP(J31,A1:B5)

    Or without table,

    =LOOKUP(J31,{0;"12/2/2001";"12/2/2006";"12/2/2009";"1/1/2012"}+0,{"Over 10";"5-10";"3-5";"0-3";""})

    Assume After 1/1/2012, you don't want to return anything.
    Regards,
    Haseeb Avarakkan

    __________________________________
    "Feedback is the breakfast of champions"

  4. #4
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Nested What If statement using date ranges

    This is another LOOKUP
    =LOOKUP(A1, DATEVALUE({"1/1/1904","12/2/2001","12/2/2006","12/2/2009","12/31/2011"}), {"over 10","5-10","3-5","0-3",""})
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ 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