Use of CASE instead of IF


Scenario

If Field1__c value is 'A' then '1' should be displayed in Field2__c.

If Field1__c value is 'B' then '2' should be displayed in Field2__c.

Else '0' should be displayed


Field2__c (formula field with return type number) equals

Using IF-


IF(

TEXT(Field1__c)='A',1,

IF(TEXT(Field1__c)='B',2,0)

)  


Using CASE-

CASE(TEXT(Field1__c), 'A', 1, 'B',2,0)


Comments