Results 1 to 2 of 2
  1. #1
    Sana Firdaus is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2017
    Posts
    22

    Nested iif else condition.


    This is quite easy to get but m not getting expected results.I have a field final,Get1,get2,get3,get4.These fields are having G,R,B,Y inside it as data.so,the formula is if get1,get2,get3,get4 all are G ,THEN Final wud be G,IF any of get1,get2,get3 and get4 is R ,then R,if any of get1,get2,get3 and get4 is Y,then Y provided none is R,else final wud be B.HERE IS THE Formula I am applying:

    iif(get1="R" or get2="R" or get3="R" or get4="R","R",iif(get1="Y" or get2="Y" or get3="Y" or get4="Y" And get1 <> "R" & get2 <> "R" & get3 <> "R" & get4 <> "R"," Y",iif(get1="G" & get2="G" & get3="G" & get4="G","G","B")))

    The problem is for all get1,get2,get3 and get4 as G,I m getting "Y" as final instead of G.please help.Thanks

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Note that it looks like you switched over mid function from using AND to using &.
    Note that & is a concatenation function, and doesn't function as AND.
    Also, in the second and third cases with you are using both OR and AND, I would recommend using parentheses to make sure the order is working as it should (i.e. surround the ORs with parentheses and the ANDs with parentheses).

Please reply to this thread with any new information or opinions.

Similar Threads

  1. IIF With Nested IIF?
    By jo15765 in forum Queries
    Replies: 5
    Last Post: 08-08-2016, 06:41 AM
  2. Nested IF
    By balajigade in forum Queries
    Replies: 3
    Last Post: 10-04-2014, 10:23 AM
  3. nested iif
    By slimjen in forum Reports
    Replies: 1
    Last Post: 03-15-2014, 09:30 AM
  4. Nested IIF
    By Oldie in forum Queries
    Replies: 1
    Last Post: 02-17-2012, 06:04 AM
  5. Replies: 3
    Last Post: 01-02-2012, 07:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums