function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
nap1nap1 

Picklist & Formulas

I was trying to write a forumla to generate a annual payment value (which would be determined by total amount devided by value taken from a pick list). Now when I try to do this, it will not work because of the pick list. I am not a developer but trying to get this done for our company. 

The three fields I am working with are picklist field (users are able to pick from 6 items), total amount value, annual amount value. I would like to define a value for the 6 item in the picklist field. So I can determine the annual amount value.  

Example: 
picklist field 
-----------------
red
white
blue
green
yellow
orange

I would like to define a numeric value for each color. One I do that I would like to do the following:

annual amount value = total amount value / pick list value

Thank you in advance for your help! 


 
James LoghryJames Loghry

Picklists unfortunately don't have a label / value aspect.  Meaning you can't configure red to mean a different value by default.  What you could do instead is create a complex formula, such as the one below, using a CASE statement to resolve each color to a numerical value, and then use that as your dividend.  For example:

 

IF(
    //Check for dividing by zero
    CASE(Picklist__c,'Red',1.0,'White',2.0,'Blue',3.0,'Yellow',4.0,0) == 0,
    //Return 0 instead of dividing by 0
    0,
    //Else return your decimal
    Total_Amount_Value__c / CASE(Picklist__c,'Red',1.0,'White',2.0,'Blue',3.0,'Yellow',4.0,0)
)
nap1nap1
Hi James, 

Thank you for helping me out with this! Do I really need a IF statement? I can just use the following, cant I?
 
Total_Amount_Value__c / CASE(Picklist__c,'Red',1.0,'White',2.0,'Blue',3.0,'Yellow',4.0,0)



 
James LoghryJames Loghry
Yes, that should work.  The IF statement is to avoid exceptions with dividing by zero is all.
nap1nap1
Thank James! I will give this a try!