0

How do I write a formula using two picklist values to equal an amount?

Here is what I want to do... If the picklist (product_category__c, "Hardware") AND if the picklist (product_sub_category__c, "Wired") then $500).

I will need to do this for several scenarios for the same field, meaning different combinations of category/subcategories. Also, Product Sub-Category picklist is dependent on what is selected in product category picklist. And finally, should I be using a formula field?

3
  • Welcome to SFSE! The focus of this site is more about helping you overcome the problems you're facing rather than just giving you the code (or formula, in this case). To that end, we highly encourage people to include the work that they've done so far. Most of the contributors here that I know work on Salesforce as their primary job, and their companies aren't paying them to do other people's work. Showing what you've tried, and explaining in detail where you're stuck, shows a "good-faith" effort to solve the problem on your part, and usually leads to a better response.
    – Derek F
    Oct 24 '17 at 22:27
  • Got it, Thanks! Very new to the salesforce world. First question and I didn't want to overload with all the errors or scenarios I tried. I was able to do the basic formula but know we added another picklist to determine criteria and amounts. I will repost question with before formula and errors on modifying formula.
    – Charles T.
    Oct 24 '17 at 22:50
  • Yeah, knowing which details are relevant, and which ones to leave out is a bit of an art (exact text of error messages is also very helpful). Also, you don't need to create a new question, you can edit this one to include additional details.
    – Derek F
    Oct 25 '17 at 0:02
2

The formula would look like this:

IF(
 AND( 
    ISPICKVAL(picklist_field, text_literal) ,
    ISPICKVAL(picklist_field, text_literal)), 
value_if_true, 
value_if_false)`

If you requirement is nothing more than what you've stated in the question, then a formula would do just fine. If the field needs to be updatable by a user in other scenarios or if there is more complex logic beyond just setting $500 as the value, then I would say consider a Workflow Rule or even an Apex Trigger.

1
  • Good answer, I think adding in information about how the Case function works with pick lists might be useful as there is at least 1 bug related to ispickval function: help.salesforce.com/… Knowing how to use both functions is always a good thing.
    – gNerb
    Oct 24 '17 at 22:51

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.