+ Reply to Thread
Results 1 to 18 of 18

Using multiple if and statements

  1. #1
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Using multiple if and statements

    Hi,

    I am using this -

    =IF(AND(R118="Y",SUM(O97:O116)>139.5),(SUM(O97:O116)*G90)/2,H90/2,IF(AND(R118="",SUM(O97:O116)>139.5),SUM(O97:O116)*G90,H90))

    In cell O118 - What am I missing?

    Thank you!

  2. #2
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Using multiple if and statements

    Your problem is you have incorrect syntax within your IF statement. Broken out by color:

    =IF(AND(R118="Y",SUM(O97:O116)>139.5),(SUM(O97:O116)*G90)/2,H90/2,IF(AND(R118="",SUM(O97:O116)>139.5),SUM(O97:O116)*G90,H90))

    The green is your initial AND statement to test against. The blue is your result if the AND statement returns TRUE for both criteria (both "Y" and >139.5). The orange is the result if the AND statement is FALSE. The formula is returning a #VALUE error because you have a trailing IF statement (which I believe you mean to have run instead for the FALSE condition) which is outside the original syntax for your initial IF statement.

    To summarize, your blue-colored or orange-colored result is what is throwing off your expected result.
    Spread the love, add to the Rep

    "None of us are as smart as all of us."

  3. #3
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    Correct -

    The result should be - if there is a Y in R118, then do either SUM(O97:O116)>139.5),(SUM(O97:O116)*G90)/2,H90/2)
    If there is a blank in R118, then do SUM(O97:O116)>139.5),(SUM(O97:O116)*G90),H90)

    Possible to do both?

  4. #4
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Using multiple if and statements

    Need to edit my previous post, the formula I posted will not return the correct value based on your logic.

    The question then is two fold - you say
    Quote Originally Posted by bryden2008 View Post
    if there is a Y in R118, then do either SUM(O97:O116)>139.5),(SUM(O97:O116)*G90)/2,H90/2)
    That would be an individual IF statement right there. The IF statement would stop. Does this supersede the need for a result of R118 is blank?
    Last edited by mcmahobt; 05-30-2017 at 11:01 AM.

  5. #5
    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
    81,277

    Re: Using multiple if and statements

    Bryden - you would be better off explaining in WORDS what you want the formula to do.
    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.

  6. #6
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    Thank you both!

    mcmahobt and Ali...I think this is it:

    If there is a Y in R118, then take the sum of O97:O116 times G90/2 or H90/2....which ever is greater.
    If R118 is blank, then take the sum of O97:O116 times G90 or H90....which ever is greater.

  7. #7
    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
    81,277

    Re: Using multiple if and statements

    Try this:

    =IF(R118="Y",SUM(O97:O116)*MAX(G90/2,H90/2),SUM(O97:O116)*MAX(G90,H90))

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,263

    Re: Using multiple if and statements

    Try

    =IF(R118="Y",SUM(O97:O116)*MAX(G90/2,H90/2),SUM(O97:O116)*MAX(G90,H90))

  9. #9
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    Thank you!
    It is returning 5921.605096

    With a Y there, the Service Charge should be 42.45

  10. #10
    Forum Expert
    Join Date
    09-11-2014
    Location
    Washington, DC
    MS-Off Ver
    2016
    Posts
    1,907

    Re: Using multiple if and statements

    Note that ALIGW's formula implies that anything other than a "Y" in R118 will return a TRUE value - not just an empty cell (""). Not incorrect logic by any means, just a point of distinction.

  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
    81,277

    Re: Using multiple if and statements

    Until Bryden defines any further requirement that he has not yet divulged, it does what he asks, but I expect you are right to point it out, as I am sure he is going to come back again and tell us that it needs to do something else if R118 is not blank or Y.

  12. #12
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,263

    Re: Using multiple if and statements

    The value in G90 is a % (10%) but H90 is value $13.95 : this suggests the test is wrong

    it should be

    =IF(R118="Y",MAX(SUM(O97:O116)*G90/2,H90/2),MAX(SUM(O97:O116)*G90,H90))

  13. #13
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: Using multiple if and statements

    =IF(R118="Y",0.5,1)*SUM(O97:O116)*MAX(G90,h90) is a little shorter and I think does the same !

  14. #14
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    You are correct in this logic, except that G90 is a % (10%), and H90 is a number (13.95).
    For a Y, we want it to take the sum of the totals times .10 divided by 2 or return the number (13.95) divided by 2.....which ever result is would be greater.
    And yes, I need to the same outcome for when there is no Y, but not divided by 2.

    Helpful - in Q118 "EOW SC" means "What would the service charge be if we serviced if every other week...."

  15. #15
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,263

    Re: Using multiple if and statements

    Formula in post #12 returns 42.45

  16. #16
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    BULLSEYE!
    Thank you John!

  17. #17
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    The only issue is that H90 and G90 can be changed by the input (user).
    And this formula came back with 5921.605096 too.

  18. #18
    Registered User
    Join Date
    07-15-2015
    Location
    new hampshire
    MS-Off Ver
    Office 2010
    Posts
    83

    Re: Using multiple if and statements

    Thank you all!

+ 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. [SOLVED] Nested if statements containing multiple and statements
    By John M. in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-22-2014, 11:48 PM
  2. Formula with multiple IF statements and IF AND statements
    By lottidotti in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-14-2013, 08:03 AM
  3. Replies: 3
    Last Post: 07-25-2013, 08:25 AM
  4. Create a macro from multiple IF statements in multiple columns
    By mdwolman in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-20-2013, 08:09 AM
  5. [SOLVED] Syntax for formula that uses multiple conditions inside of multiple IF statements
    By njmiller31 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-02-2013, 11:55 AM
  6. Multiple nested IF statements and AND statements
    By TonyGetz in forum Excel General
    Replies: 2
    Last Post: 12-14-2010, 03:07 AM
  7. Replies: 12
    Last Post: 05-15-2009, 08:38 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