2

I'm struggling with one of my formula fields, its mainly around that second if statement where i need to check if the income schedule = 8409 and do something different than the final if statement but i keep getting the same error and im not sure where i have gone wrong any help would be appreciated!

Error: Incorrect number of parameters for function 'IF()'. Expected 3, received 2

IF(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"IGNORE"),"",

IF(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"8409"),
TEXT(IF(Deferred_Revenue_End_Date__c = Deferred_Revenue_Start_Date__c,1,
((YEAR(Deferred_Revenue_End_Date__c)*12) +MONTH(Deferred_Revenue_End_Date__c))
-
((YEAR(Deferred_Revenue_Start_Date__c)*12) +MONTH(Deferred_Revenue_Start_Date__c))
+
IF(DAY(Deferred_Revenue_Start_Date__c)<=DAY(Deferred_Revenue_End_Date__c),1,0)
)) & 'Month 8409'),


IF(NOT(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"")),TEXT(PricebookEntry.Product2.Income_Schedule__c),
TEXT(IF(Deferred_Revenue_End_Date__c = Deferred_Revenue_Start_Date__c,1,
((YEAR(Deferred_Revenue_End_Date__c)*12) +MONTH(Deferred_Revenue_End_Date__c))
-
((YEAR(Deferred_Revenue_Start_Date__c)*12) +MONTH(Deferred_Revenue_Start_Date__c))
+
IF(DAY(Deferred_Revenue_Start_Date__c)<=DAY(Deferred_Revenue_End_Date__c),1,0)
)) & ' Month')

)

1 Answer 1

1

The error is in this IF statement here:

  IF(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"8409"),
    TEXT(
      IF(Deferred_Revenue_End_Date__c = Deferred_Revenue_Start_Date__c,
        1,
        ((YEAR(Deferred_Revenue_End_Date__c)*12) +MONTH(Deferred_Revenue_End_Date__c))
        -
        ((YEAR(Deferred_Revenue_Start_Date__c)*12) +MONTH(Deferred_Revenue_Start_Date__c))
        +
        IF(DAY(Deferred_Revenue_Start_Date__c)<=DAY(Deferred_Revenue_End_Date__c),1,0))) & 
        'Month 8409'),

This IF statement, when we remove all of the various sub-clauses, looks like this:

IF(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"8409"),
  TEXT(...) & 'Month 8409'),

As you can see, there's only 2 parameters, but IF requires 3 parameters. In other words, you've unbalanced your parentheses somewhere else. It looks like the parentheses after 8409 is in the wrong place, and should be moved near the end.

Try this:

IF(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"IGNORE"),
  "",
  IF(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"8409"),
    TEXT(
      IF(Deferred_Revenue_End_Date__c = Deferred_Revenue_Start_Date__c,
        1,
        ((YEAR(Deferred_Revenue_End_Date__c)*12) +MONTH(Deferred_Revenue_End_Date__c))
        -
        ((YEAR(Deferred_Revenue_Start_Date__c)*12) +MONTH(Deferred_Revenue_Start_Date__c))
        +
        IF(DAY(Deferred_Revenue_Start_Date__c)<=DAY(Deferred_Revenue_End_Date__c),1,0))) & 
        'Month 8409',
    IF(NOT(ISPICKVAL(PricebookEntry.Product2.Income_Schedule__c,"")),TEXT(PricebookEntry.Product2.Income_Schedule__c),
TEXT(IF(Deferred_Revenue_End_Date__c = Deferred_Revenue_Start_Date__c,1,
((YEAR(Deferred_Revenue_End_Date__c)*12) +MONTH(Deferred_Revenue_End_Date__c))
-
((YEAR(Deferred_Revenue_Start_Date__c)*12) +MONTH(Deferred_Revenue_Start_Date__c))
+
IF(DAY(Deferred_Revenue_Start_Date__c)<=DAY(Deferred_Revenue_End_Date__c),1,0)
)) & ' Month')

))
2
  • You are a lifesaver just tested this as well and works a treat thank you! Jun 14, 2017 at 10:03
  • 2
    @ClevelandDan You're welcome! It's pretty easy to get all those parentheses mangled up in statements like this. I typically use Programmer's Notepad to write formulas, because it highlights matching parentheses, which makes it easy to see mistakes like this. That's actually how I solved this question as quick as I did.
    – sfdcfox
    Jun 14, 2017 at 10:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .