0

I cant understand the below Salesforce Formula. Could someone help me to understand this?

IF ( ISBLANK(Actual_Finish_Date__c), 
Deadline__c - IF(ISBLANK( 
Actual_Start_Date__c), Kickoff__c, 
Actual_Start_Date__c ) + 1, 
Actual_Finish_Date__c - IF(ISBLANK( 
Actual_Start_Date__c), Kickoff__c , 
Actual_Start_Date__c )+1)

2 Answers 2

1

Formula Operators and Functions

IF(logical_test, value_if_true, value_if_false)
Determines if expressions are true or false. Returns a given value if true and another value if false

ISBLANK(expression)
Determines if an expression has a value and returns TRUE if it does not. If it contains a value, this function returns FALSE.

Assuming that Deadline__c, Kickoff__c, Actual_Start_Date__c and Actual_Finish_Date__c are Date fields

IF(
    ISBLANK( Actual_Start_Date__c ),
    Kickoff__c,
    Actual_Start_Date__c
)

This formula check whether Actual_Start_Date__c hasn't a value, if so returns the value of Kickoff__c, otherwise the one of Actual_Start_Date__c
E.G.

Actual_Start_Date__c Kickoff__c Result
null 2020-01-01 2020-01-01
2020-01-05 2020-01-01 2020-01-05
IF( ISBLANK(Actual_Finish_Date__c),
    Deadline__c -
    IF(
        ISBLANK( Actual_Start_Date__c),
        Kickoff__c,
        Actual_Start_Date__c
    )
    + 1,
    Actual_Finish_Date__c -
    IF( ISBLANK( Actual_Start_Date__c),
        Kickoff__c,
        Actual_Start_Date__c
    )
    +1
)

If Actual_Finish_Date__c is null, it returns the days between Deadline__c and Kickoff__c plus one if Actual_Start_Date__c is null, or the days between Deadline__c and Actual_Start_Date__c plus one if the latter isn't null.
If Actual_Finish_Date__c isn't null, it return the days between Actual_Finish_Date__c and Kickoff__c plus one if Actual_Start_Date__c is null, or the days between Actual_Finish_Date__c and Actual_Start_Date__c plus one if the latter isn't null.

Actual_Finish_Date__c Deadline__c Actual_Start_Date__c Kickoff__c Result
null 2020-01-10 null 2020-01-02 9
2020-01-20 2020-01-10 null 2020-01-02 19
null 2020-01-10 2020-01-05 2020-01-02 6
2020-01-20 2020-01-10 2020-01-05 2020-01-02 16
1
  • Thank you for the detailed explanation!!
    – Salesforce
    Jan 12 at 1:49
0

This formula could have been written as:

BLANKVALUE(Actual_Finish_Date__c, Deadline__c) - 
BLANKVALUE(Actual_Start_Date__c, Kickoff__c) + 1

This should make it easier to understand. We want to calculate the number of days between two dates. We'll take either the Actual Finish Date or the Deadline (if no Finish Date is provided), and subtract the Actual Start Date or the Kickoff Date (if no Start Date is provided).

The subtraction of two dates results in a number for the number of days between the two. We then add 1 day to count the start date to get the proper count (e.g. if you start today and end today, it took you one day to complete the project).

1
  • Thank you for the detailed explanation!!
    – Salesforce
    Jan 12 at 1:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.