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
Cameron BumsteadCameron Bumstead 

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)
Sanjay Mulagada 11Sanjay Mulagada 11
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)
 ))))))))

 
Cameron BumsteadCameron Bumstead
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?
Sanjay Mulagada 11Sanjay Mulagada 11
This is tough, I really can't see a way can you try this, -
IF( 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 <= 1, 5, 0)
 ))))))))

Its okay not to check for Profile_Completeness_Percent__c >=0 and also in the last step since it goes to step only when it returns False in the other IF statements