+ Start a Discussion
Bryn Leahy 18Bryn Leahy 18 

Number formula to calculate only for certain picklist value

I have a number formula field that should only calculate when a specific picklist value is selected.


I have a working number formula to count the months between two date fields:
IF(
(CloseDate  -  Monthly_Min_Start_Date_Earliest__c)  / 365 * 12 < 1, 1, (CloseDate - Monthly_Min_Start_Date_Earliest__c) / 365 * 12)

It should only calculate if Type = Existing Upsell
ISPICKVAL(Type,'Existing Upsell')


I have attempted:
IF(
ISPICKVAL(Type,'Existing Upsell'),
(CloseDate  -  Monthly_Min_Start_Date_Earliest__c)  / 365 * 12 < 1, 1, (CloseDate - Monthly_Min_Start_Date_Earliest__c) / 365 * 12)

which results in error: Incorrect number of parameteres for Function 'IF()'. Expected 3, received 4.

I have tried a second IF statement before the formula date, but it resulted in the same error.

Any help is much appreciated!


 
ShirishaShirisha (Salesforce Developers) 
Hi Bryn,

Greetings!

Since you are using the IF statement it should have action for both true and false due to which you might be getting the error.

If the picklist value is Existing Upsell then it will calculate the value and I would suggest you to add the condition where if the picklist value is not the Existing Upsell.

Reference:https://developer.salesforce.com/forums/?id=906F00000008w5NIAQ

Please mark it as best answer if it helps you to fix the issue.

Thank you!

Regards,
Shirisha Pathuri