How can I create an IF statement with multiple conditions?

  • 0
  • 1
  • Question
  • Updated 3 years ago
  • Answered

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! 

Photo of bintu85

bintu85

  • 90 Points 75 badge 2x thumb

Posted 3 years ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 62,944 Points 50k badge 2x thumb
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>")
Photo of bintu85

bintu85

  • 90 Points 75 badge 2x thumb
Thanks so much!  This is exactly what I was looking for and everything appears to be working as intended.