Search code examples
salesforcesalesforce-lightningsalesforce-service-cloudsalesforce-communities

Creating a formula field


I have a picklist field with following values: 1)fall 2019 2)Winter 2019 3)summer 2018

I have one more formula filed in the same object. If an user selects Fall 2019 from the picklist , the formula field should return 8193. 8 - default for all cases 19 - year 3 - value for fall(in the same manner 2 is value for winter and 4 is value for summer).

Please help me to write a formula.


Solution

  • This is how your formula would be:

    IF (NOT(ISBLANK(TEXT(Picklist__c))), "8" & RIGHT(TEXT(Picklist__c), 2) & CASE(LEFT(TEXT(Picklist__c),Find(" ", TEXT(Picklist__c))-1), "Fall", "3", "Winter", "2", "Summer", "4", "") , "")

    Change Picklist__c with your Pick List field api name.