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
WPCMSWPCMS 

Formula: case with &&'s

I am trying to create a formula that will show what type of service description our object is.

 

I know how to do the case for one field:

 

CASE(text( Waste_Type__c ),"SW","Solid Waste Can","OCC","Cardboard Can","RM","Recyclable Materials Can","")

 

But I need to take this one step further and have two fields matched to return the complete service description.

 

In my words:

 

If waste type = "SW" && can_size_c <10 then return "Solid waste can", 

else if waste type = "SW" && can-size_c >10 then return "Solid Waste Roll Off"

 

 

Thank you in advance

Best Answer chosen by Admin (Salesforce Developers) 
tstrongtstrong

The code below is what you can use if what you wrote out previously is the logic you are trying to enforce.  So you are saying, if waste type is "SW" and Can size is less than 10, the value is "Solid waste can."  If waste type is "SW" and Can size is greater than 10, the value is "Solid Waste Roll Off".  Otherwise, it is null.

 

If (ISPICKVAL (Waste_Type__c, "SW") && can_size_c <10, "Solid waste can", 

If ISPICKVAL (Waste_Type__c, "SW") && can-size_c >10, "Solid Waste Roll Off", null)

 


 

All Answers

tstrongtstrong

I would forego using the CASE function and just write your formula something like this:

 

If (Waste_Type__c = "SW" && can_size_c <10, "Solid waste can", 

If Waste_Type__c = "SW" && can-size_c >10, "Solid Waste Roll Off", null)

 

 

If your Waste_Type__c field is a pick list, you'll have to use ISPICKVAL (Waste_Type__c, "SW")

 

WPCMSWPCMS
The waste type is a pick list. How do I use this formula with out the case function?
tstrongtstrong

The code below is what you can use if what you wrote out previously is the logic you are trying to enforce.  So you are saying, if waste type is "SW" and Can size is less than 10, the value is "Solid waste can."  If waste type is "SW" and Can size is greater than 10, the value is "Solid Waste Roll Off".  Otherwise, it is null.

 

If (ISPICKVAL (Waste_Type__c, "SW") && can_size_c <10, "Solid waste can", 

If ISPICKVAL (Waste_Type__c, "SW") && can-size_c >10, "Solid Waste Roll Off", null)

 


 

This was selected as the best answer
WPCMSWPCMS
I finally got around to testing this out. It works. Thank you.