Updated: Dec 25, 2021
What Does This Post Cover?
- What is the CASE() function and when do I use it over an IF/THEN statement?
- You want to stay within compile limits - You want to create a cleaner look - You want it to be easier to read for other internal users
In this example:
We will be breaking down a use case where you have several conditions and explain WHY this is going to be much much better to do it this way versus going the route of some gnarly IF/THEN statement.
#1 What Is the CASE() Function?
Definition: Checks a given expression against a series of values. If the expression is equal to a value, returns the corresponding result. If it is not equal to any values, it returns the else_result.
When do I use it? The CASE() function is a powerful Salesforce tool that allows users to simplify formula writing, stay within compile limits, and create cleaner, easier to read functions versus using long and clunky nested IF() statements
Case Function: CASE(expression, value1, result1, value2, result2,...,else_result)
What I have posted above is really the best way to describe the CASE() functionality. It's one of those functions that exist but a lot of the time is overlooked and not used nearly as much as it should be, from what I have seen in my experience. I say use this over the IF/THEN just based solely on the fact that it's so much easier to read and if you have to edit it, way easier to modify.
#2 Concatenate Quicker
Have you ever needed to quickly wrap your text in quotations for a formula? How about add a comma after each line? Yes? Great news! Start using this tool for quicker results vs. jumping into excel and using a concatenate formula. Check out the video to see this LIVE in action
#3 Live Example
Check out the youtube video below to see how we would use this function in real life and how to set it up from start to finish 🍿🎬