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
Fingerroll23Fingerroll23 

IF - THEN logic in a formula field

I have set-up different 'opportunity value' calculation fields for different opportunities. In one of the formulas, I would like to add some conditions to the field. The field should calculate as it is set-up to, but if first part of the calculation field comes back as 0 (zero), then the field should come up as zero. Here is the specific example.

Opportunity field: Opportunity_Value_Contract
Data type: Formula
( Per_Meg_Price__c * Commited_Megs__c * Contract_length_months__c )+ OTC__c

NOW - if the first part of this formula ( Per_Meg_Price__c * Commited_Megs__c * Contract_length_months__c ) calculates to (0) zero, I want the entire field to return a (0) zero. Even if there is an OTC_c entered.

I am looking for some ‘if – then’ logic. I have tried to go into advanced formula and use 'IF' logic, but I can't get the syntax right. My instincts tell me it is rather easy for someone more versed in this logic.

Guidance anyone? Thanks!

NPMNPM
What is the syntax error you are getting?  This should be close to what you want.  The part before the first comma is the condition that is (IF) true (THEN) the field will be set to the value between the first comma and second comma. If the condition is false  (ELSE) the field will be set to the value after the second comma.
 
Try this (not tested). 
 
IF( Per_Meg_Price__c * Commited_Megs__c * Contract_length_months__c =0, 0,Per_Meg_Price__c * Commited_Megs__c * Contract_length_months__c + OTC)
Fingerroll23Fingerroll23

NPM, many thanks for your input. Finally had the time to get back and tackle this issue. Your clarifying how to use commas as the 'then' statement helped me grasp how to use the validation rule. I never did get a precise reason whey the syntax was incorrect with my initial attempts, but by using an isnull logic with the If/then (IF,,) rule, I was able to get the calculation field to behave the way I wanted it to. Gracias!

NPMNPM
De nada.
 
Glad it helped, 
 
Best of luck!