Inspired by a lot of problems related to formulas posted in Answers Community ,I decided to put blog series “Learn Salesforce Formulas with Examples“ and here I am with fifth post in the Series.
Main motive for this blog is not to teach you how to begin with formula but how to keep a grip and make a better understanding on it..So stay tuned and I will be providing a lot of examples with explanations in this series which would help you understand more about formulas
User wants to create a formula Date field on Opportunity which will return end date of the following quarter after an opportunity has been marked “Closed Won”.
ISPICKVAL(StageName, “Closed Won”),
YEAR(CloseDate) = YEAR(TODAY())
IF(MONTH(CloseDate)<=9,DATE(YEAR(TODAY()), 12,31),DATE(YEAR(TODAY())+1, 3,31)))),
so majorly the above formula explains the return of last date of quarter
User needs to add a dynamic hyperlink to a text or formula field.
There is a field- ABC which is added to a SFDC text field called ABC__c from an external system (which is none of the business for us right now)
User needs a way to make the ABC__c field display the ABC number only which is just like a shipment number only but hyperlink to the external system URL
There is one more logic which needs to be checked :
If ABC__c value has 18 characters, Hyperlink =
If ABC__c value had 12 characters, Hyperlink =
where Field Name is ABC__c
LEN( ABC__c ) = 18,
HYPERLINK(“http://www.vinaychaturvedi.com/&ABC__c, ‘Info at Vinay Chaturvedi’),
LEN(ABC__c ) = 12,
HYPERLINK(“http://www.vinaychaturvedi.com/&ABC__c&cntry_code=us”, ‘Info at Vinay US’),
ISBLANK(ABC__c ), “”,
so here we have used Hyperlink function and three level nested IF which check first if the length is 18 digit,If no then checks the length is 15 else,it gives the output as Invalid Hyperlink.
User wants a formula for a validation rule when the isvalidated__c checkbox is checked and a text field ABC__c is not equal to ‘Vinay’
ABC__c <> ‘Vinay’,
This is a simple formula,just a tip that We can use != or <> for Not Equal to
User wants a formula to display the I am working on formula to convert an Event_Date__c value to a “Day of the Week”.
MOD(Event_Date__c – DATE( 1900, 1, 7 ), 7 ),
0, “1. Sunday”,
1, “2. Monday”,
2, “3. Tuesday”,
3, “4. Wednesday”,
4, “5. Thursday”,
5, “6. Friday”,
Here we have used MOD method for subtraction hard coded date for example and use CASE function.
User wants to write a Membership Discount formula field that calcuates % based on the Membership Type. Here’s a description of the conditions:
If Membership_Type__c Picklist = Normal, make Membership_Discount__c = 0%
If Membership_Type__c Picklist = VIP, make Membership_Discount__c = 25%
If Membership_Type__c Picklist = VVIP, make Membership_Discount__c = 50%
Please note that the picklist type “Membership_Type__c” doesn’t require TEXT(Membership_Type__c)