0

We have a list of 30 countries with specific rates at which our company must withhold taxes, and we wish to create a formula field in Salesforce to automatically compute the rate based on the user's country. This is straightforward to setup, but the current syntax we have isn't suitable for a long list like this.

For example: If UserCountry=UK, 0% If UserCountry=Australia, 5% If UserCountry=Bangladesh, 0% etc....

What would be the best syntax to use for this?

1
2

You can accomplish this with the case function.

// As noted in the comments
CASE(expression,
value1, result1,
value2, result2,
else_result)

Above, if the value in expression is == to value1, the field value will be result1 and so on. If no values match the expression, the field value will be else_result.

For your use case:

e.g.

CASE(UserCountry, 
"UK", 0%,
"AU", 5%,
etc...)
3
  • 1
    Small note, the final value in a CASE will be an else. EX: CASE(expression, value1, result1, value2, result2,...,else_result) – Jesse Milburn Jan 12 '16 at 14:48
  • @JesseMilburn Edited the answer to include your note, Thanks – Antonio Manente Jan 12 '16 at 14:51
  • Thanks for the help!It looks like I am running into a syntax error: CASE(TEXT(Request__r.UserCountry__c), “United States", 0%, “United Kingdom", 0%, 30%) – Daniel Foster Jan 12 '16 at 17:53
0

@Daniel Foster the values need to be in double quotes too.

CASE(TEXT(Request__r.UserCountry__c), “United States", "0%", “United Kingdom", "0%", "30%")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.