Tell me more ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

I want to use a dropdown list for attributing values to a field. However, for the end user, I want to show easy labes instead of numbers.

I wonder how I can set up a formula to transform that text to integers.

The labels would be: easy, medium and hard. They should be mapped to 0.5, 1 and 1.5.

I need to transform those to compute them in another formula.

Here is what it would look like in a basic Python function:

def mapping(x):
    y = 1
    if x == 'easy':
         y = 0.5
    elif x == 'medium':
         y = 1
    else:
         y = 1.5

How can I solve this using formulas in Salesforce?

share|improve this question

1 Answer

up vote 2 down vote accepted

if you wanted the user to choose from text values in the picklist, you could do a conversion to numeric factor in the formula itself, using the CASE function.

Suppose you have the three picklist values 'Easy', 'Medium', 'Hard' then you could rewrite your formula field as

amount__c * CASE(Boost_Factor__c, 'Easy', 0.5, 'Medium', 1, 'Hard', 1.5, 1)   //final argument is the default if no match
share|improve this answer
 
Thank you, works perfectly! –  Martin Betz May 14 at 9:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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