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
Amanda JonesAmanda Jones 

Write formula to run calculation only on field that does not contain a zero value

I have two currency fields on my campaigns object. If one field is calculated, by default the other is not and has a zero balance.

I need to write a formula that decides when a field is not equal to zero and then performs a calculation on that field.

Here is what I have so far:

IF(NOT(
ISBLANK(First_Time_STI_Total_Cost__c)),
First_Time_STI_Total_Cost__c-Total_Amount_Received__c,
null
)

OR

IF(NOT(
ISBLANK(Repeat_STI_Total_Cost__c)),
Repeat_STI_Total_Cost__c-Total_Amount_Received__c,
null
)
But it doesn't work. Please help.
Nitin PaliwalNitin Paliwal
Hi Amanda,
Try this..

IF(
    NOT(
        OR(ISBLANK(First_Time_STI_Total_Cost__c),ISNULL(First_Time_STI_Total_Cost__c))
    ),
    First_Time_STI_Total_Cost__c-Total_Amount_Received__c,
    IF(
        NOT(
            OR(ISBLANK(Repeat_STI_Total_Cost__c),ISNULL(Repeat_STI_Total_Cost__c))
        ),
        Repeat_STI_Total_Cost__c-Total_Amount_Received__c,
        null
    )
)
Amanda JonesAmanda Jones
Hello Nitin,

Thank you so much for the response. I cannot test the formula because it won't compile. Here is the error I received:  Error: Compiled formula is too big to execute (21,146 characters). Maximum size is 5,000 characters.

Is there a way to use the Case function to make it smaller?