+ Reply to Thread
Results 1 to 7 of 7

Multiple AND and IF

  1. #1
    Registered User
    Join Date
    02-06-2020
    Location
    Rotterdam
    MS-Off Ver
    365
    Posts
    3

    Multiple AND and IF

    Hello, my first post here :D


    I am trying to make a formula to test for certain cases, it looks like this, but doesnt work... Any help appreciated! For easy of reading I have put every case on a new line, of course this is not so in Excel.

    There are 16 cases: Cells C27 to C30 can be 1 or 2 and should give the a,b,c,d or e as result in C32.

    1 1111 a
    2 1112 a
    3 1121 b
    4 1122 a
    5 1211 b
    6 1212 a
    7 1221 c
    8 1222 b
    9 2111 c
    10 2112 b
    11 2121 d
    12 2122 c
    13 2211 d
    14 2212 c
    15 2221 e
    16 2222 d


    =IF(AND(C27 = 1; C28 = 1; C29 = 1; C30 = 1);"PL = a";
    =IF(AND(C27 = 1; C28 = 1; C29 = 1; C30 = 2);"PL = a";
    =IF(AND(C27 = 1; C28 = 1; C29 = 2; C30 = 1);"PL = b";
    =IF(AND(C27 = 1; C28 = 1; C29 = 2; C30 = 2);"PL = a";
    =IF(AND(C27 = 1; C28 = 2; C29 = 1; C30 = 1);"PL = b";
    =IF(AND(C27 = 1; C28 = 2; C29 = 1; C30 = 2);"PL = a";
    =IF(AND(C27 = 1; C28 = 2; C29 = 2; C30 = 1);"PL = c";
    =IF(AND(C27 = 1; C28 = 2; C29 = 2; C30 = 2);"PL = b";
    =IF(AND(C27 = 2; C28 = 1; C29 = 1; C30 = 1);"PL = c";
    =IF(AND(C27 = 2; C28 = 1; C29 = 1; C30 = 2);"PL = b";
    =IF(AND(C27 = 2; C28 = 1; C29 = 2; C30 = 1);"PL = d";
    =IF(AND(C27 = 2; C28 = 1; C29 = 2; C30 = 2);"PL = c";
    =IF(AND(C27 = 2; C28 = 2; C29 = 1; C30 = 1);"PL = d";
    =IF(AND(C27 = 2; C28 = 2; C29 = 1; C30 = 2);"PL = c";
    =IF(AND(C27 = 2; C28 = 2; C29 = 2; C30 = 1);"PL = e";
    =IF(AND(C27 = 2; C28 = 2; C29 = 2; C30 = 2);"PL = d";"ERROR")


    EDIT: of course I tried to end the formula like this "....C30 = 2);"PL = d";"ERROR"))))))))))))))))" Did not work...
    Last edited by noobie2020; 02-06-2020 at 07:14 AM.

  2. #2
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Multiple AND and IF

    you don't have any results for the IF formulas.
    this...
    =IF(AND(C27 = 1; C28 = 1; C29 = 1; C30 = 1);"PL = a";=IF(AND(C27 = 1; C28 = 1; C29 = 1; C30 = 2);"PL = a";
    You don't need the additional "=" in front of each IF, you also don't state what should happen for each IF, you have IF(AND(this and this and this)with this ... now do this, then if not go to the second IF. You don't have that.
    follow the directions in the yellow banner at the top if you want additional help.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  3. #3
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Multiple AND and IF

    and what is PL=a etc? Is PL a cell, where is PL=a coming from?

  4. #4
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Multiple AND and IF

    this could be a shorter way to write it but still you'd have to define what to do with each item...
    =if(and(or(sum(c27:c30)=4,sum(c27:c30)=5,sum(c27:c30)=6),"PL = a"),"do this",if(and(or(sum(c27:c30)=4,sum(c27:c30)=5,sum(c27:c30)=6),"PL = b"), etc. until the end.
    and replacing the commas with semi-colons per your regional settings.
    Of course this is untested.

  5. #5
    Registered User
    Join Date
    02-06-2020
    Location
    Rotterdam
    MS-Off Ver
    365
    Posts
    3

    Re: Multiple AND and IF

    Thanks for answering but it's not that straight forward. As you can see in the table i made changing a 1 to a 2 can yield different results, so it's not as simple as adding thing up. It has to do with the performance level of risk reduction measures...

  6. #6
    Registered User
    Join Date
    02-06-2020
    Location
    Rotterdam
    MS-Off Ver
    365
    Posts
    3

    Re: Multiple AND and IF

    Thanks for your help!

    I just solved it, I did not need the = every time and I needed 16 ) to close the 16 that were opened before... Logic is beautiful!

    EDIT: this is the formula now: (ALS = IF, EN = AND)


    =ALS(EN(C27 = 1; C28 = 1; C29 = 1; C30 = 1);"PL = a";ALS(EN(C27 = 1; C28 = 1; C29 = 1; C30 = 2);"PL = a";ALS(EN(C27 = 1; C28 = 1; C29 = 2; C30 = 1);"PL = b";ALS(EN(C27 = 1; C28 = 1; C29 = 2; C30 = 2);"PL = a";ALS(EN(C27 = 1; C28 = 2; C29 = 1; C30 = 1);"PL = b";ALS(EN(C27 = 1; C28 = 2; C29 = 1; C30 = 2);"PL = a";ALS(EN(C27 = 1; C28 = 2; C29 = 2; C30 = 1);"PL = c";ALS(EN(C27 = 1; C28 = 2; C29 = 2; C30 = 2);"PL = b";ALS(EN(C27 = 2; C28 = 1; C29 = 1; C30 = 1);"PL = c";ALS(EN(C27 = 2; C28 = 1; C29 = 1; C30 = 2);"PL = b";ALS(EN(C27 = 2; C28 = 1; C29 = 2; C30 = 1);"PL = d";ALS(EN(C27 = 2; C28 = 1; C29 = 2; C30 = 2);"PL = c";ALS(EN(C27 = 2; C28 = 2; C29 = 1; C30 = 1);"PL = d";ALS(EN(C27 = 2; C28 = 2; C29 = 1; C30 = 2);"PL = c";ALS(EN(C27 = 2; C28 = 2; C29 = 2; C30 = 1);"PL = e";ALS(EN(C27 = 2; C28 = 2; C29 = 2; C30 = 2);"PL = d";"FOUT"))))))))))))))))
    Last edited by noobie2020; 02-17-2020 at 09:15 AM.

  7. #7
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Multiple AND and IF

    deleted as you solved your issue.
    Glad you got it to work for you. Please don't forget to mark the post as solved using the thread tools dropdown at the top of the post.

+ 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] Lookup multiple criteria in multiple columns in multiple rows; return true if exists
    By ufdlim in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 06-07-2019, 02:03 PM
  2. Replies: 2
    Last Post: 05-26-2015, 07:29 PM
  3. Replies: 20
    Last Post: 03-13-2013, 04:15 PM
  4. [SOLVED] Large spreadsheet; multiple scores on multiple dates for multiple students
    By MelindaCapri in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 11-16-2012, 06:03 PM
  5. Replies: 5
    Last Post: 11-04-2010, 06:02 AM
  6. Multiple charts over multiple sets of data over multiple worksheets.
    By matrocka in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-12-2007, 10:01 AM
  7. Replies: 7
    Last Post: 09-15-2005, 05:05 PM

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