The Everyday Function: A Simplified Guide to Formulas in Salesforce

 • 
Formulas in Salesforce are an awesome admin tool but can be difficult to work with at times.  This blog series, ‘The Everyday Function’ by Tom Hoffman, brings Salesforce formulas down from the cloud and into everyday life.

The Everyday Function: Case

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.

It’s also a little confusing, so let’s bring it into the real world.

My wife, Mary, says she is going out shopping.  I ask her where she is going, she, of course, says, ‘not sure, just out, need a few things.’  Well, I also need a few things.

So I say, ‘Ok Mary, if you are going to the mall, can you grab me some of those fun socks I like? If you are going to swing by Target (because you KNOW that is happening) I need some deodorant.  If you are not going to either place, can you at least bring me home some unsweetened green tea from 7/11. Thanks”!

This is a Case function!

Case(WifeDestination, ‘Mall’, ‘Fun Socks’, ‘Target’, ‘Deodorant’, ‘Green Tea’)

Case(Expression, result1, return1, result2, return2, catch-all)

A case function has 4 components:

1: Expression: the condition you are evaluating

2: Result: the value you are checking for

3: Return: what you want to return for each value

4: Catch-all: if none of these defined results are true, then just do this

What formulas would you like to see taken down from the cloud and into everyday terms that you can understand? Let us know in the comments!