Discussions

Expand all | Collapse all

How can I create an IF statement with multiple conditions?

  • 1.  How can I create an IF statement with multiple conditions?

    Posted 03-21-2016 18:17

    Hello all,I am trying to create an IF statement with multiple conditions that will return a yes or no depending on if one of the conditions are met.  

    Here is a sample of my formula: 

    If(([Related Candidate (ref) - Job Code])="AACH25,AACH41,ADEV31,ADEV32,ADEV33,ADEV34,ADEV41,ADEV42,ADEV43,"<Font color=RED>YES</font>","null")

    QB accepts the formula, however, it does not work (I think because it is looking at the conditions as a whole).  Do I need to write an IF statement for each of the "AACH25,AACH41,ADEV31,ADEV32,ADEV33,ADEV34,ADEV41,ADEV42,ADEV43" conditions, or can I use OR in between?  I have about 320 codes that I need to include so if there's any easier way to do this that would be fantastic.

    Thank you! 



  • 2.  RE: How can I create an IF statement with multiple conditions?

    Posted 03-21-2016 18:43
    I will answer your question, but there is a much much much (320 much's) better way.

    var text Red = "<font color=red>YES</font>";

    IF(

    [Related Candidate (ref) - Job Code] = "AACH25", $red,

    [Related Candidate (ref) - Job Code] = "AACH41", $red,

    [Related Candidate (ref) - Job Code] = "ADEV31", $red,

    etc

    [Related Candidate (ref) - Job Code] = "ADEV320", $red)





    But the better way is to use excel to load up a table of these codes.  Make the Key field of that table the code field.  Add a formula checkbox field to the table called [Code exists?] with the formula of 

    true



    Then using the [Related Candidate (ref) - Job Code] field on the right hand side of a new relationship to that Codes table, lookup the value for [Code exists?]

    Then your formula would be simple:

    IF([Code exists?], "<font color=red>YES</font>")


  • 3.  RE: How can I create an IF statement with multiple conditions?

    Posted 03-21-2016 20:23
    Thanks so much!  This is exactly what I was looking for and everything appears to be working as intended.