+ Reply to Thread
Results 1 to 14 of 14

Thread: If Formula

  1. #1
    Registered User
    Join Date
    03-08-2011
    Location
    Denver
    MS-Off Ver
    Excel 2003
    Posts
    6

    If Formula

    The formula below can produce two results. I need a third that will be a 1 if the first two conditions are not met.

    Thanks

    =IF(OR((M17+R17)=N17,(M17+R17)<N17),0,-1)

  2. #2
    Forum Guru Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    2,784

    Re: If Formula

    That formula should be simplified as

    =IF(M17+R17<=N17,0,-1)

    and you are already saying you want -1 if the conditions are not met. What condition(s) would require a 1 as the result?

  3. #3
    Valued Forum Contributor MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Seattle, WA
    MS-Off Ver
    Excel 2010
    Posts
    5,300

    Re: If Formula

    Hi rwhalls and welcome to the forum. How about
    =IF(AND((M17+R17)<>N17,(M17+R17)>=N17),1,IF(OR((M17+R17)=N17,(M17+R17)<N17),0,-1))
    One test is worth a thousand opinions.
    Click the * below to say thanks.

  4. #4
    Registered User
    Join Date
    03-08-2011
    Location
    Minneapolis, Minnesota, USA
    MS-Off Ver
    Excel 2010
    Posts
    5

    Re: If Formula

    =if((m17+r17)>n17,1,if((m17+r17)<=n17,0,-1))
    This will give a 1 if the sum of M17 and R17 is greater than N17.
    This will give a 0 if the sum of M17 and R17 is equal to or less than N17.
    This will give a -1 if there is an error in the formula (word in the cell instead of a number.)
    Last edited by eg0e; 03-08-2011 at 05:09 PM.

  5. #5
    Registered User
    Join Date
    03-08-2011
    Location
    Denver
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: If Formula

    Thanks. I had to take out the 0 before the -1 to make it work

  6. #6
    Registered User
    Join Date
    03-08-2011
    Location
    Denver
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: If Formula

    I put back the 0 before the – 1 but there is a problem. When M17+R17 is less than N17 the result is 0 and it should be -1

  7. #7
    Forum Guru Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    2,784

    Re: If Formula

    I think you should be showing us what formula you are using!!

  8. #8
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: If Formula

    Quote Originally Posted by rwhalls
    When M17+R17 is less than N17 the result is 0 and it should be -1
    Perhaps then you actually want:

    =SIGN(M17+R17-N17)

  9. #9
    Registered User
    Join Date
    03-08-2011
    Location
    Denver
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: If Formula

    This formula does not produce a -1

    =IF(AND((M17+R17)<>N17,(M17+R17)>=N17),1,IF(OR((M17+R17)=N17,(M17+R17)<N17),0,-1))

  10. #10
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: If Formula

    For the time being try to explain requirements in words rather than failed formulas which in truth are hard to follow (logically)

    The SIGN formula will generate -1, 0, 1 depending on result of M17+R17 less N17 with results as follows:

    If M17+R17 is less than N17 then -1
    If M17+R17 is equal to N17 then 0
    If M17+R17 is greater than N17 then 1

    If that's not what you require please clarify with actual examples / values.

  11. #11
    Registered User
    Join Date
    03-08-2011
    Location
    Denver
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: If Formula

    Here's the formula:

    =IF(AND((M17+R17)<>N17,(M17+R17)>=N17),1,IF(OR((M17+R17)=N17,(M17+R17)<N17),0,-1))

  12. #12
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: If Formula

    If you feel the formula above works that's great obviously but from a logic perspective it makes little sense given -1 would never be generated
    either M17+R17 >N17 (1) or it is <= N17 (0) ... on which basis both the AND and the OR tests are unnecessary - single tests of > and <= would have the same effect

    If you need to follow up please explain your requirements in words

  13. #13
    Registered User
    Join Date
    03-08-2011
    Location
    Denver
    MS-Off Ver
    Excel 2003
    Posts
    6

    Re: If Formula

    N17 can be equal to, less than or greater than M17+R17. If equal to a 0 is entered. If less than a -1 is entered. If greater than a 1 is entered.

  14. #14
    Forum Moderator DonkeyOte's Avatar
    Join Date
    10-22-2008
    Location
    Suffolk, UK
    MS-Off Ver
    2002, 2007 & 2010
    Posts
    21,423

    Re: If Formula

    This is what the SIGN formula in post # 8 does only in reverse given we assumed the -1 occurred where M+R < N rather than the other way around

    =SIGN(N17-M17-R17)
    will generate -1, 0 or 1 as you outline.

+ 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.2.0