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
Sydney PedigoSydney Pedigo 

Can I use the last variable in the CASE function to put other CASE function? Like a nested CASE?

I made this formula and am not sure why I keep getting an error that I'm missing an end parentheses. I wasn't sure if it was because I was using the CASE function incorrectly or if what I want to do isn't possible with CASE. And I can't think of an apparent way to put this in an IF statement. Would love help!

(FYI, the Neighborhood__c is a lookup field, so I put in the ID for the record. The other way of putting a value in quotation marks didn't work either). 


This is the formula: 
CASE( Neighborhood__c,
a2o1M000000n2AXQAY, "South Dallas"
a2o1M000000n2ADQAY, "West Dallas",

       CASE(Neighborhood__r.Parent_Neighborhood__c,
       a2o1M000000n2AXQAY, "South Dallas"
       a2o1M000000n2ADQAY, "West Dallas"

            CASE(Neighborhood__r.Parent_Neighborhood__r.Parent_Neighborhood__c, 
            a2o1M000000n2AXQAY, "South Dallas"
            a2o1M000000n2ADQAY, "West Dallas",

                 CASE(Neighborhood__r.Parent_Neighborhood__r.Parent_Neighborhood__r.Parent_Neighborhood__c, 
                 a2o1M000000n2AXQAY, "South Dallas"
                 a2o1M000000n2ADQAY, "West Dallas", NULL)
            
            )
       )
)
Alain CabonAlain Cabon
Hi,

The message with the missing end parentheses is often misleading because it is more often missing commas.

CASE( Neighborhood__c,
"a2o1M000000n2AXQAY", "South Dallas" ,
"a2o1M000000n2ADQAY", "West Dallas",

       CASE(Neighborhood__r.Parent_Neighborhood__c,
       "a2o1M000000n2AXQAY", "South Dallas" ,
       "a2o1M000000n2ADQAY", "West Dallas"  ,

            CASE(Neighborhood__r.Parent_Neighborhood__r.Parent_Neighborhood__c, 
            "a2o1M000000n2AXQAY", "South Dallas"  ,
            "a2o1M000000n2ADQAY", "West Dallas",

                 CASE(Neighborhood__r.Parent_Neighborhood__r.Parent_Neighborhood__r.Parent_Neighborhood__c, 
                 "a2o1M000000n2AXQAY", "South Dallas"  ,
                 "a2o1M000000n2ADQAY", "West Dallas", NULL)
            
            )
       )
)

WARNING: don't copy/paste a formula but just add the missing commas manually at the end of each line.
Sydney PedigoSydney Pedigo
Thank you Alain! That totally fixed some of the problem (you're right, I wasn't careful with the copy and paste). 

But the formula still isn't working. It's a field on Activity to show a specific text (South Dallas or West Dallas" based off the value in a lookup field (the Neighborhood__r.Parent_Neighborhood__c and etc.). Am I not referencing the value in the lookup field correctly? I've tried (in quotation marks) the object ID and the URL link and don't know how else to reference this. 


Sydney