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?
Best Answer
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