+ Reply to Thread
Results 1 to 18 of 18

Nested IF/AND not returning expected value

  1. #1
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Question Nested IF/AND not returning expected value

    Good Morning!

    I know I'm close, but I can't figure out why my nested IF/AND statement isn't returning the appropriate value based on range. Here is my formula. Is anyone able to assist?

    Thank you!

    Please Login or Register  to view this content.

  2. #2
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Nested IF/AND not returning expected value

    Try
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Last edited by Pepe Le Mokko; 10-19-2021 at 09:05 AM.

  3. #3
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Nested IF/AND not returning expected value

    Thank you so much for the reply! I am getting an empty cell, but I should not be. The value in the corresponding cell is 605.96, I would have expected it to return with a value of 2

  4. #4
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Nested IF/AND not returning expected value

    I posted a suggestion corrected the formula in post #2, please disregard my previous answer (also check if your numbers are real numbers (right aligned) not text looking like numbers)

  5. #5
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Nested IF/AND not returning expected value

    When I attempt the above formula, I am getting an error which indicates I am using too many arguments for this function.

  6. #6
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    472

    Re: Nested IF/AND not returning expected value

    Post a workbook otherwise we can only guess what's wrong with your data.

  7. #7
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Nested IF/AND not returning expected value

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

  8. #8
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    472

    Re: Nested IF/AND not returning expected value

    btw - your formulas are error prone as they're only piecewiese defined.

    If your value is e.g. 500.5, an empty cell is returned.
    If you defined: =IF(AND(C4>=200,C4<=500),1,IF(AND(C4>=501, C4<=1500)... - what happens to numbers between 500 and 501?
    You should say: <=500 and then >500 and so on.

  9. #9
    Forum Expert
    Join Date
    09-25-2015
    Location
    Milan Italy
    MS-Off Ver
    office 365
    Posts
    1,775

    Re: Nested IF/AND not returning expected value

    A
    B
    C
    D
    E
    F
    1
    value code code
    2
    605.96
    2
    200
    500
    1
    3
    501
    1500
    2
    4
    1501
    2500
    3
    5
    2501
    5000
    4
    6
    5001
    5


    Type number in A2


    B2=IFERROR(LOOKUP(A2,D2:E6,F2:F6),"")
    Last edited by CARACALLA; 10-19-2021 at 09:15 AM.

  10. #10
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Nested IF/AND not returning expected value

    Quote Originally Posted by Pepe Le Mokko View Post
    Perhaps
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    That is giving me the #spill error.

    Just a bit of background - the purpose of this is to determine how many payment plans for each duration we currently have. 1 is 1 year, 2 is 2 years, etc. It is all based on balance and this was the way I thought to do this.

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Nested IF/AND not returning expected value

    There are instructions at the top of the page explaining how to attach your sample workbook.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  12. #12
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    472

    Re: Nested IF/AND not returning expected value

    Quote Originally Posted by kristina View Post
    That is giving me the #spill error.
    This formula doesn't spill.
    Clearly you're doing something different than what you're telling us.

  13. #13
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Nested IF/AND not returning expected value

    I believe I've managed to attached a very small example of the data and spill error.
    Attached Files Attached Files
    Last edited by AliGW; 10-19-2021 at 09:37 AM. Reason: PLEASE don't quote unnecessarily!

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Nested IF/AND not returning expected value

    You were trying to use whole column ranges - why???

    Try this:

    =IF(D2<200,"",IF(AND(D2>=200,D2<=500),1,IF(AND(D2>=501, D2<=1500),2, IF(AND(D2>=1501,D2<=2500),3, IF(AND(D2>=2501,D2<=5000),4,5)))))

    This would be easier:

    =LOOKUP(D2,{0,200,501,1501,2501,5001},{"",1,2,3,4,5})
    Last edited by AliGW; 10-19-2021 at 09:46 AM. Reason: Typo

  15. #15
    Valued Forum Contributor
    Join Date
    02-06-2013
    Location
    Germany
    MS-Off Ver
    365
    Posts
    472

    Re: Nested IF/AND not returning expected value

    You're trying to spill column D but only starting at row 2, hence the spilling is exceeding the length of the spreadhseet.
    You need to limit the range mor appropriately.

  16. #16
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Nested IF/AND not returning expected value

    @AliGW

    This worked! And in answer to your question, I must have clicked that on accident. Thank you so very much - you and everyone else that took the time to help me troubleshoot - much appreciated!
    Last edited by AliGW; 10-19-2021 at 09:48 AM. Reason: PLEASE don't quote unnecessarily!

  17. #17
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Nested IF/AND not returning expected value

    I hope you used the more compact LOOKUP option.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of all those who offered help.

  18. #18
    Registered User
    Join Date
    02-24-2009
    Location
    Washington
    MS-Off Ver
    Office 365
    Posts
    17

    Re: Nested IF/AND not returning expected value

    I have gone through and added reputation to everyone that responded and I did use the shorter version. I will mark this as solved. Thank you again!
    Last edited by AliGW; 10-19-2021 at 10:04 AM. Reason: PLEASE stop quoting unnecessarily!

+ 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. Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 09-07-2005, 12:05 AM
  2. Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 09:05 PM
  3. Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 PM
  4. [SOLVED] Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 06:05 PM
  5. Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 10:05 AM
  6. [SOLVED] Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 09-06-2005, 08:05 AM
  7. Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 07:05 AM
  8. Nested "if" not returning expected value
    By Michael E W in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-06-2005, 03:05 AM

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