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
         y = 1.5

How can I solve this using formulas in Salesforce?


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

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.