0

I have a formula field in Salesforce which uses the below mentioned formula and it often results in divide by zero error and if i use conditions to check if the resulting value is zero, then it results in compile size error.

Est_Purchase_Price__c / ( Total_Equity__c - Est_Loan_Fees__c - Est_Interest__c - Est_Debt_Fee__c + Est_Proceeds__c )

Is there a way where i can overcome this issue?

0

You'll have to check the denominator and provide a pre-determined answer if the denominator is 0.

Since your denominator is so long, for readability and usability, I'd recommend creating another formula field for your denominator. Then in your original formula field you can reference the new denominator formula field.

| improve this answer | |
  • Even if i create another formula field for denominator and use them in the original formula field, i still get the "Compiled formula is too big to execute" error. – Ean Dec 13 '18 at 17:06
  • I think you're going to just have to use a trigger to set this value. Formula fields have a compile size limit that considers the size of all of the formula's components. So if you're referencing a formula field multiple times, it might be counting each instance's size. Easiest option would be to create a trigger on insert/update that calculates and sets this field. – Ryan Dinesman Dec 13 '18 at 17:22
  • Thanks for your response. I am also thinking about using workflow field update to perform the calculation but i wanted to see whether there is any other way that i don't know about. – Ean Dec 13 '18 at 17:32
  • Workflow could work too. I'm skeptical that you'll be able to do this with just formula fields; the variables you're using are just too large. Here's hoping someone else proves me wrong though. Good luck! – Ryan Dinesman Dec 13 '18 at 17:41

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.