Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted

# Case function error

I'm trying to create a case function instead of using a logic function and am running into an issue. "Profile_Completeness_Percent__c" is a percentage and I am trying to return a score based on that percentage range. Am I missing something obvious? I keep getting a "Error: Incorrect argument type for function 'CASE()'." error.

CASE( Profile_Completeness_Percent__c ,
Profile_Completeness_Percent__c >= 0 && Profile_Completeness_Percent__c <= (55/100), 1,
Profile_Completeness_Percent__c > (55/100) && Profile_Completeness_Percent__c <= (59/100), 1.5,
Profile_Completeness_Percent__c > (59/100) && Profile_Completeness_Percent__c <= (64/100), 2,
Profile_Completeness_Percent__c > (64/100) && Profile_Completeness_Percent__c <= (69/100), 2.5,
Profile_Completeness_Percent__c > (69/100) && Profile_Completeness_Percent__c <= (74/100), 3,
Profile_Completeness_Percent__c > (74/100) && Profile_Completeness_Percent__c <= (80/100), 3.5,
Profile_Completeness_Percent__c > (80/100) && Profile_Completeness_Percent__c <= (89/100), 4,
Profile_Completeness_Percent__c > (89/100) && Profile_Completeness_Percent__c <= (95/100), 4.5,
Profile_Completeness_Percent__c > (95/100) && Profile_Completeness_Percent__c <= 1, 5, 0)
Hey Cameron, Case function uses the syntax  "CASE(expression, value1, result1, value2, result2,...,else_result)" you cannot check for ranges,
I would do the above the logic using Nestes IF statements,

IF(Profile_Completeness_Percent__c >= 0 && Profile_Completeness_Percent__c <= (55/100), 1,
IF(Profile_Completeness_Percent__c > (55/100) && Profile_Completeness_Percent__c <= (59/100), 1.5,
IF(Profile_Completeness_Percent__c > (59/100) && Profile_Completeness_Percent__c <= (64/100), 2,
IF(Profile_Completeness_Percent__c > (64/100) && Profile_Completeness_Percent__c <= (69/100), 2.5,
IF(Profile_Completeness_Percent__c > (69/100) && Profile_Completeness_Percent__c <= (74/100), 3,
IF(Profile_Completeness_Percent__c > (74/100) && Profile_Completeness_Percent__c <= (80/100), 3.5,
IF(Profile_Completeness_Percent__c > (80/100) && Profile_Completeness_Percent__c <= (89/100), 4,
IF(Profile_Completeness_Percent__c > (89/100) && Profile_Completeness_Percent__c <= (95/100), 4.5,
IF(Profile_Completeness_Percent__c > (95/100) && Profile_Completeness_Percent__c <= 1, 5, 0)
))))))))

Sanjay,

I had that exact formula before and the issue I'm running into is that I'm trying to combine multiple fields that have logic formulas and am running into the character limit issue. Is there any other known way to shorten this?