function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nidhi ShuklaNidhi Shukla 

How to use if else on formula field

Hi 
I am writing this formula field but I don't see Else option. How can I complete this? Completion requirement is else 'Undergraduate', "UGA"

IF(TGTX_Counselor_Assignment_Override__c, NULL, 

IF( Record_Share_CCAS__c || Record_Share_CPS__c || Record_Share_ESIA__c || Record_Share_GSEHD__c || Record_Share_GWSPH__c || Record_Share_ONDS__c || Record_Share_SEAS__c || Record_Share_SMHS__c || Record_Share_SOB__c || Record_Share_SON__c || TEXT(TargetX_SRMb__Level__c) = 'Graduate',"GRAD", 
Nayana KNayana K
IF(TGTX_Counselor_Assignment_Override__c, NULL, IF( Record_Share_CCAS__c || Record_Share_CPS__c || Record_Share_ESIA__c || Record_Share_GSEHD__c || Record_Share_GWSPH__c || Record_Share_ONDS__c || Record_Share_SEAS__c || Record_Share_SMHS__c || Record_Share_SOB__c || Record_Share_SON__c || TEXT(TargetX_SRMb__Level__c) = 'Graduate', "GRAD", "UGA"))

2nd if is inside the else part of first if.

Above works like this:

if(TGTX_Counselor_Assignment_Override__c)
{
  output = null;
}
else if(condition1 || condition2 || ... || conditionN)
{
     output = "GRAD";
}
else
{
    output = "UGA";
}

 
Nidhi ShuklaNidhi Shukla
I read in the community that we can not use Else in formula field. I tried to use Else it's throwing an error.
Nayana KNayana K
You can use else but syntax is different. As per the documentation:

IF(logical_test, value_if_true, value_if_false)
Checks whether a condition is true, and returns one value if TRUE and another value if FALSE.

Let's say, if probability is > 50, we want to set the formula field value as green. If less or equal, yellow.

You can do:
IF(Opportunity.Probability > 0.5 , "green", "yellow")

which is nothing but:
if(Opportunity.Probability > 0.5)
{
value = "green";
}
else
{
value = "yellow";
}