# What happens with an IF formula with multiple TRUE conditions?

I have a multi nested IF statement like below - what happens if a field meets more than one condition - is there a rule to determine which value gets returned?

IF(CONTAINS( Custom__Name__c , "/cs/"), "01u3800000NmuloAAB",
IF(CONTAINS(Custom__Name__c , "/gergerg/"), "01u3800000NmuloAAB",
IF(CONTAINS(Custom__Name__c , "popopopop"), "01u3800000NmulsAAB",
IF(CONTAINS(Custom__Name__c , "programmatic"), "01u3800000MTR6BAAX",
IF(CONTAINS(Custom__Name__c , "tototototot"), "01u3800000MSUqPAAX",
IF(CONTAINS(Custom__Name__c , "new"), "01u3800000MSUqZAAX",
IF(CONTAINS(Custom__Name__c , "old"), "01u3800000NmulnAAB",

IF(CONTAINS(Custom__Name__c , "etc"), "01u3800000MSVhHAAX",
IF(CONTAINS(Custom__Name__c , "uno"), "01u3800000NmulqAAB",

“else result”)))))))))

• you will get the value based on the first condition met, it won't check further conditions. So you need to be very cautious while deciding the order of the conditions. Dec 6, 2019 at 15:48

Formulas are evaluated in order, which usually means from left to right. The net result is that the first condition to be met will win. For example:

IF(FALSE, 0, IF(FALSE, 1, IF(TRUE, 2, IF(FALSE, 3, IF(TRUE, 4, 5)))))


The answer will be 2, because it was the first condition to be met.

More abstractly, you can say that the conditions follow the "true path"; the value 4 is not on the true path, because it doesn't follow the path of Boolean values:

         T F
0 T F
1 T F
2 T F
3 T F
4 5


For example, F F F T would have a result of 3; you just need to follow the T and F columns on each row until you get a result. In this code, F F T F T results in a value of 2, because when you follow F F T, you get a value of 2; no further branches are evaluated.

IF statement basically works as IF and Else in the nested if statements of yours Conditions are evaluated into the further nests if they are the condition is true/false (your case it is false).

So, Basically, if CONTAINS( Custom__Name__c , "/cs/") is evaluated to True you will be returned (String) 01u3800000NmuloAAB. no further evaluations are carried out.

Alternately, use the CASE function. Here's the documentation: https://help.salesforce.com/articleView?id=customize_functions_a_h.htm&type=5#CASE Here's the syntax: CASE(expression,​value1, result1, value2,​result2,...,​else_result)