Discussions
- General Development
- Schema Development
- Apex Code Development
- Visualforce Development
- Formulas & Validation Rules
- Security
- Mobile
- Force.com Sites & Site.com
- Chatter Development
- Java Development
- .NET Development
- Perl, PHP, Python & Ruby
- Desktop Integration
- APIs and Integrations
- Visual Workflow
- Apple, Mac and OS X
- VB and Office Development
- AppExchange Directory & Packaging
- Salesforce Labs & Open Source Projects
- Other Salesforce Applications
- Jobs Board
- Force.com Discussion Boards
- :
- Developer Boards for Force.com and Database.com
- :
- Formulas & Validation Rules Discussion
- :
- Re: Need formula for generating numeric value base...
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Need formula for generating numeric value based upon text pick list value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-31-2012 01:05 PM
I have four custom Account object pick lists. Each pick list text field has four values: No Risk, Low Risk, Medium Risk,and High Risk. Contractual__c is one of the four pick lists.
I have an other custom field "C-RiskValue__c" defined as a number. I need a formula to autogenerate a numeric value in this second field based upon the pick list value selected. I found several suggestions but just cannot get the syntax correct. Suggestions?
IF(ISPICKVAL(Contractual__c, "No Risk"), 0.00,
IF(ISPICKVAL(Contractual__c, "Low Risk"), 0.01,
IF(ISPICKVAL(Contractual__c, "Medium Risk"), 0.05,
IF(ISPICKVAL(Contractual__c, "High Risk"), 0.50,
null))))
Re: Need formula for generating numeric value based upon text pick list value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
10-31-2012 03:53 PM
Try using a CASE statement instead:
CASE(Contractual__c, "Low Risk", 0.01, "Medium Risk", 0.05, "High Risk", 0.5, 0.0)
The default here returns 0, which would occur when the value was "No Risk" or if a picklist value was not selected.
Senior Product Manager, Declarative Apps
Salesforce.com
Re: Need formula for generating numeric value based upon text pick list value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-01-2012 07:13 AM
Re: Need formula for generating numeric value based upon text pick list value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-01-2012 08:05 AM
I noticed on another posting that putting the field name in quotes so it is defined as text should fix the error Field Contractual __c may not be used in this type of formula. That did return "no syntax errors" and I was able to save:
CASE("Contractual__c", "Low Risk", 0.01, "Medium Risk", 0.05, "High Risk", 0.5, 0.0)
Unfortunately, the new field that should display the numeric value based upon the pick list field, shows nothing even if I modify to another pick list value.
Re: Need formula for generating numeric value based upon text pick list value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-01-2012 03:30 PM
Wrapping the field name in quotes compares the string "Contractual__c" to "Low Risk" etc, which will never return a match. So while it may prevent a syntax error, it definitely won't do what you need it to do.
So back to the syntax error... that's very strange. Picklists should be allowed in a CASE function.
Check #1: You've verified that Contractual__c is a picklist?
Check #2: If Contractual__c is a picklist, try the same formula with a different picklist? You mentioned you had 4 of them on the page, so try another -- or create a test picklist. It doesn't matter if the values are different, we just want to figure out why the syntax error is happening.
Senior Product Manager, Declarative Apps
Salesforce.com
Re: Need formula for generating numeric value based upon text pick list value
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
11-09-2012 07:51 PM
Almost there. If Contractual__c is a picklist, you have to wrap it in TEXT():
CASE(TEXT(Contractual__c), "Low Risk", 0.01, "Medium Risk", 0.05, "High Risk", 0.5, 0.0)
Salesforce Fast
If a reply to a post answers your question or resolves your problem, please mark it as the solution to the post so that others may benefit.

