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
rohit chormallerohit chormalle 

The Question regarding formula field

the Question Is  regarding Leave  Record ,  to calculate no of days based on start date  and End Date  and Also There is one Picklist field as a Leave Type and the picklist Values are 1) First half  2)  Second Half and 3) Full day 
 if user Select The First half With start date  and Date As same Then in no of days it should populate  0.5(no_of_Days__c is a formula Field)

 This formula Working fine for without picklist values we need to only do for FIRST HALF and SECOND HALF  Picklist Values .
  IF(End_Date__c == Start_Date__c, 1, (End_Date__c - Start_Date__c )+ 1)


 
Sai PraveenSai Praveen (Salesforce Developers) 
Hi Rohit,

Do you mean to add firsthalf and second half in the above formula?

Thanks,
 
rohit chormallerohit chormalle
yes
Denitsa StoychevaDenitsa Stoycheva
Hi, 
I am new to validation rules and I am trying to create one for Industry picklist. Would this be something you can help with? Sorry if its in the wrong thread. 
The logic I am going after is the following: 
IF the industry value uploaded / edited on the Account object IS outside the picklist values throw an error, otherwise populate.
It would be amazing if I can get some support on this. Thank you!!! 
Shri RajShri Raj
To include the logic for the Leave Type picklist field, you can add an additional condition to the existing formula. Here is an example of how you can modify the formula:
IF(Leave_Type__c == 'First Half', 0.5, IF(Leave_Type__c == 'Second Half', 0.5, IF(End_Date__c == Start_Date__c, 1, (End_Date__c - Start_Date__c )+ 1)))
In this formula, the first condition checks if the Leave Type is "First Half" and if so, sets the no_of_Days__c field to 0.5. The second condition checks if the Leave Type is "Second Half" and if so, sets the no_of_Days__c field to 0.5. The final condition is the existing formula that calculates the number of days between the Start Date and End Date for all other Leave Types.