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
gringoesegringoese 

Formula w/ 2 fields added together for Case parameter

I am trying to create a formula field with a Case statement that has 2 other number fields added together for it's parameter. It looks like this:

 

CASE ((Custom_Number Field_1__c +  Custom_Number Field_2__c), >=100, "Value is Greater than 100", >=50, "Value is Greater than 50",  >=1, "Value is Greater than 1")

 

I keep trying to alter the syntax slightly, but no matter what I get one of 2 error messages:

Error: Incorrect number of parameters for function 'CASE()'. Expected 6, received 7

or

Error: Syntax error. Found '>='

 

What am I doing wrong? Is it even possible to do a Case statement like this or do I have to switch to an IF?

 

SwarnasankhaSwarnasankha

The Case function has the following Syntax - CASE (Expression, Value1, Result1, Value2, Result2, ......, else Result) where in the Value parameter cannot accept comparitive values like >100 or >=100. Try using an IF Statement; it would look something like this:

 

IF
(
(Custom_Number Field_1__c +  Custom_Number Field_2__c) >= 100,
"Value is Greater than 100",
IF
(
(Custom_Number Field_1__c +  Custom_Number Field_2__c) >= 50,
"Value is Greater than 50",
IF
(
(Custom_Number Field_1__c +  Custom_Number Field_2__c) >= 1,
"Value is Greater than 1",""
)
)
)
gringoesegringoese

That's what I wound up doing. I just tried to use a CASE to make it less verbose.