0

I am trying to create a formula field to display a "clean" value for our revenue. It is a formula based on opportunity fields and it's a field displayed in the opportunity itself. We have several record types in our org and I am testing different fields including the record type. I am receiving this error message when I check the syntax

Error: Incorrect parameter type for function 'if()'. Expected Number, received Text

and I don't understand why.

if(RecordType.Name="New Biz - Site Level",

if(Is_Natural_Expansion__c=true,  MRR_estimated__c, 

if(ISPICKVAL(Type, "Upsell"), MRR_estimated__c, 

if(MRR_at_deployment__c>0, MRR_at_deployment__c, MRR_at_deployment__c))),

if(ISPICKVAL(Type, "Upsell"),

MRR_estimated__c,
""))
1
  • formula return type should be number. change the formula return type from text to number. And also your formula was not clear what exactly you were trying to achieve. Nov 3, 2022 at 11:57

1 Answer 1

2

From the documentation on the IF() function

Make sure your value_if_true and value_if_false expressions are the same data type.

So

IF(
    ISPICKVAL(Type, "Upsell"),
    MRR_estimated__c,
    ""
)

is invalid because the "value if true" is a number, and your "value if false" is a string. Indeed, this is what the error says.

So instead of "", something like 0 would be appropriate.

Beyond that, you ought to be able to simplify this formula. Multiple layers of using the same field (in the condition or the true/false results) is a hallmark of "you should take a step back and try to think if there's a better way to do it".

Also, IF(<boolean value> = true, ...) can always be simplified to IF(<boolean value>, ...)

1
  • This is really great. Thank you ! Pretty ease after all. I do agree with you I can simplify the formula but in terms of logic with our business, it was better to double check the "type" field. Thank you very much for you help ! Nov 3, 2022 at 14:15

You must log in to answer this question.

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