Some Useful Formula Fields

1) Get Week Day

CASE( 
MOD( DATEVALUE( CreatedDate ) - DATE( 1990, 1, 7 ), 7 ), 
0, "Sunday", 
1, "Monday", 
2, "Tuesday", 
3, "Wednesday", 
4, "Thursday", 
5, "Friday", 
"Saturday" 
)


2) Get Month Year Based on PickList Values


if( 
ispickval(Status__c,'THIS_MONTH'), 
(case(Month(Date__c), 
1,"JAN", 
2,"FEB", 
3,"MARCH", 
4,"APRIL", 
5,"MAY", 
6,"JUNE", 
7,"JULY", 
8,"AUG", 
9,"SEP", 
10,"OCT", 
11,"NOV", 
12,"DEC", " " 
) +'-'+ TEXT(year(Date__c))) , 


if(ispickval(Status__c,'NEXT_MONTH'), 
(case(Month(Date__c) + 1 , 
1,"JAN", 
2,"FEB", 
3,"MARCH", 
4,"APRIL", 
5,"MAY", 
6,"JUNE", 
7,"JULY", 
8,"AUG", 
9,"SEP", 
10,"OCT", 
11,"NOV", 
12,"DEC", 
13, "JAN", " " 
) +'-'+ if((Month(Date__c) + 1)>12, TEXT(year(Date__c) + 1), TEXT(year(Date__c)))), 


if(ispickval(Status__c,'NEXT_TO_NEXT_MONTH'), 
(case(Month(Date__c) + 2 , 
1,"JAN", 
2,"FEB", 
3,"MARCH", 
4,"APRIL", 
5,"MAY", 
6,"JUNE", 
7,"JULY", 
8,"AUG", 
9,"SEP", 
10,"OCT", 
11,"NOV", 
12,"DEC", 
13,"JAN", 
14, "FEB", " " 
) +'-'+ if((Month(Date__c) + 2)>12, TEXT(year(Date__c) + 1), TEXT(year(Date__c)))), 



if(ispickval(Status__c,'LAST_MONTH'), 
(case(Month(Date__c)-1 , 
1,"JAN", 
2,"FEB", 
3,"MARCH", 
4,"APRIL", 
5,"MAY", 
6,"JUNE", 
7,"JULY", 
8,"AUG", 
9,"SEP", 
10,"OCT", 
11,"NOV", 
12,"DEC", 
0, "DEC", " " 
)+'-'+ if((Month(Date__c) - 1) = 0, TEXT(year(Date__c)-1), TEXT(year(Date__c)))), 



"") 

)))



OutPut : If Date__c : 16/04/2016 And Status__c Value is "This Month">>> Then O/P is April 2106

3) Get Tick and Cross Image Using farmula fields


Step First: Upload tick and cross image in document and clik on image copy the image url address

and Now create the farmula field

IF(TEXT(Type__c) == "A",IMAGE("https://c.ap1.content.force.com/servlet/servlet.ImageServer?id=0159000000CBMdY&oid=00D90000000K90z&lastMod=1451724592000","Active"), IMAGE("https://c.ap1.content.force.com/servlet/servlet.ImageServer?id=0159000000CBMdT&oid=00D90000000K90z&lastMod=1451724558000","Expired") )


4) Create Formula field for Multi select Pick list values

SUBSTITUTE( 
IF(INCLUDES(TestMulti__c, "A"), "A;", NULL) + 
IF(INCLUDES(TestMulti__c, "B"), "B;", NULL) + 
IF(INCLUDES(TestMulti__c, "C"), "C;", NULL) + 

IF(INCLUDES(TestMulti__c, "D"), "D;", NULL) + ".", ";.", NULL)


5) Get Month Name from Date value


CASE(MONTH( DATEVALUE( CreatedDate )), 
1, "January", 
2, "February", 
3, "March", 
4, "April", 
5, "May", 
6, "June", 
7, "July", 
8, "August", 
9, "September", 
10, "October", 
11, "November", 
12, "December", 
"None")

6) Time stamp Formula for Calculate 5 min

CreateDate-0.038

Comments

Popular posts from this blog

Salesforce Spring 16 Release Exam (Maintenance Exam Q&A) for Developer 201 Admin

Show Hyper Link On Add Error in Salesforce Trigger

Show the Success Message before Redirecting the Detail page on Visualforce Page