1

I'm trying to write a (checkbox) formula field that looks at the stage name as well as days in a current stage. I am receiving an error that reads: "Incorrect parameter type for operator '>='. Expected Date, received Number"

IF(AND(ISPICKVAL(StageName, 'Initial Interest'), ((TODAY() - Initial_Interest_Date__c) >= 20)), TRUE,
    IF(AND(ISPICKVAL(StageName, 'Qualified Interest'), ((TODAY() - Qualified_Date__c) >= 30)), TRUE,
        IF(AND(ISPICKVAL(StageName, 'Solutioning'), ((TODAY() - Solutioning_Date__c) >= 40)), TRUE,
            IF(AND(ISPICKVAL(StageName, 'Contract Review'), ((TODAY() - Contract_Review_Date__c) >= 30)), TRUE,
                IF(AND(ISPICKVAL(StageName, 'Proposal Sent'), ((TODAY() - Solutioning_Date__c) >= 40)), TRUE,
                    IF(AND(ISPICKVAL(StageName, 'Waiting for Signature'), ((TODAY() - Contract_Review__c) >= 30)), TRUE,
                        FALSE)
                )
            )
        )
    )
)

Could anyone help?

5
  • 1
    Is Contract_Review__c a date? If not, that would explain the error.
    – sfdcfox
    Commented May 16, 2017 at 14:47
  • All of the fields labeled 'date' are in Salesforce as date fields
    – Carolyn
    Commented May 16, 2017 at 14:58
  • @Carolyn you're comparing Contract_Review__c to TODAY() in the last IF(), fox is suggesting that that field is not a date, and therefore causing the issue Commented May 16, 2017 at 15:04
  • Oh thank you! Staring at your own code makes you miss the most basic things! Thank you @BrianMansfield and @sfdcfox!
    – Carolyn
    Commented May 16, 2017 at 15:06
  • @Carolyn Gave you an optimized version, as well. Give it a spin.
    – sfdcfox
    Commented May 16, 2017 at 15:17

1 Answer 1

1

One of the fields was not a date, and a date minus a number is another date, which can't be compared to a number.

Also, you can optimize your formula to be much more readable:

TODAY() -
CASE(StageName,
  'Initial Interest', Initial_Interest_Date__c,
  'Qualified Interest', Qualified_Date__c,
  'Solutioning', Solutioning_Date__c,
  'Contract Review', Contract_Review_Date__c,
  'Proposal Sent', Solutioning_Date__c,
  'Waiting for Signature', Contract_Review__c, 
  TODAY())
>=
CASE(StageName,
  'Initial Interest', 20,
  'Qualified Interest', 30,
  'Solutioning', 40,
  'Contract Review', 30,
  'Proposal Sent', 40,
  'Waiting for Signature', 30, 
  0)

(Note: exact syntax may vary, but this should be close).

You must log in to answer this question.

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