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
RoxyGirlRoxyGirl 

Need help with IF formula

I need to return a value of 0 if the field has 0, if the value is greater than 0 I need to divide by another field and return that value.

Here is the formula I have, it is giving me a syntax error saying incorrect paramaters expected 3 recieved 2

 

 

IF (Total_Event_Cost__c =0,0)  > 0  /  NumberOfWonOpportunities

 

Thank you!!!

Best Answer chosen by Admin (Salesforce Developers) 
Ritesh AswaneyRitesh Aswaney

I'm guessing then we check for both values being greater than zero before calculation, else return a default value of 0.

 

IF ((Total_Event_Cost__c > 0 && NumberOfWonOpportunities>0), Total_Event_Cost__c /  NumberOfWonOpportunities, 0  )

All Answers

Ritesh AswaneyRitesh Aswaney

the syntax is

If (Condition, Value if true, Value if False)

 

So,

IF (Total_Event_Cost__c <> 0, Total_Event_Cost__c /  NumberOfWonOpportunities, 0  )

RoxyGirlRoxyGirl

Thank you for your reply, unfortunately it is still returning Error in my cost per closed deal field when the value in the numberofwonopportunities is 0

 

What I need to do is divide the total event cost by the number of won opps and return a value (which will appear in the cost per closed deal field) even if it is 0. Maybe I am doing this the wrong way but when there is a value greater than 0 it does calculate correctly, I am lost.

Any suggestions would be greatly appreciated.

 

Thanks!

Ritesh AswaneyRitesh Aswaney

I'm guessing then we check for both values being greater than zero before calculation, else return a default value of 0.

 

IF ((Total_Event_Cost__c > 0 && NumberOfWonOpportunities>0), Total_Event_Cost__c /  NumberOfWonOpportunities, 0  )

This was selected as the best answer
RoxyGirlRoxyGirl

That did the trick,

 

Thank you SO much, you saved me a lot of time and hair pulling.

 

Take care

Ritesh AswaneyRitesh Aswaney

No problem :)