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
Cara RingwoodCara Ringwood 

Creating a formula field dependent on a picklist value

I have a picklist for ethnicity sub category, and I am trying to create an Ethnicity formula field which automatically updates depending on the picklist value. 
An example of the formula:
IF (Ethnicity_Sub_Category__c>= Vietnamese, "Asian", 
IF (Ethnicity_Sub_Category__c>= Asian Other, "Asian"

Error message:
Error: Syntax error. Found 'Asian'

I tried a few other formulas but also received Error: Field Ethnicity_Sub_Category__c is a picklist field. Picklist fields are only supported in certain functions.

Is there a way to do this?

Thanks in advance
Best Answer chosen by Cara Ringwood
Naveen KNNaveen KN
Hi Cara, 

Please find the tested code. Make changes to the picklist field as per your requirement. 
 
IF(ISPICKVAL(Country__c , "India"), 'Asia', 
			IF(ISPICKVAL(Country__c , "USA"), 'Americas', '')
		)

Test results:

Image 1

User-added image

Image 2
User-added image


Hope it will resolve the issue. Share the results here.

Naveen
Team Codengine.in

All Answers

Raj VakatiRaj Vakati
Try like this 
 
IF (Text(Ethnicity_Sub_Category__c)= "Vietnamese", "Asian", "")
IF (Text(Ethnicity_Sub_Category__c)= "Asian Other", "Asian","")

 
Naveen KNNaveen KN
Hi Cara, 

Please find the tested code. Make changes to the picklist field as per your requirement. 
 
IF(ISPICKVAL(Country__c , "India"), 'Asia', 
			IF(ISPICKVAL(Country__c , "USA"), 'Americas', '')
		)

Test results:

Image 1

User-added image

Image 2
User-added image


Hope it will resolve the issue. Share the results here.

Naveen
Team Codengine.in
This was selected as the best answer
Cara RingwoodCara Ringwood
@Naveen

Thank you so much, it worked! Really appreciate your help

Final formula:

IF(ISPICKVAL(Ethnicity_Sub_Category__c , "Bangladeshi"), 'Asian', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Chinese"), 'Asian', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Indian"), 'Asian', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Pakistani"), 'Asian', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Vietnamese"), 'Asian', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Asian Other"), 'Asian', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Angolan"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Caribbean"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Congolese"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Ghanaian"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Nigerian"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Sierra Leonean"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Somali"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Sudanese"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Black African Other"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Black Asian"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Black British"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Black Other"), 'Black', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "White and Black African"), 'Mixed', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "White and Black Caribbean"), 'Mixed', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "White and Asian"), 'Mixed', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Mixed Other"), 'Mixed', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "White British"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "White Irish"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Traveller of Irish Heritage"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Icelanders"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Liechtensteiner"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Swiss"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Norwegian"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Albanian"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Bulgarian"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Romanian"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Orthodox Jewish"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Polish"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Other White Background"), 'White', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Afghan"), 'Other Ethnic Group', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Kurdish"), 'Other Ethnic Group', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Turkish Cypriot"), 'Other Ethnic Group', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Greek Cypriot"), 'Other Ethnic Group', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Latin/South/Central America"), 'Other Ethnic Group', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Arab"), 'Other Ethnic Group', 
IF(ISPICKVAL(Ethnicity_Sub_Category__c, "Other Ethnic"), 'Other Ethnic Group','') 
)))))))))))))))))))))))))))))))))))))))))

Example of test:

User-added image

Best,

Cara
Naveen KNNaveen KN
Hi Cara, I am glad that it resolved the issue. Thanks for confirming back. 

Happy coding, 
Naveen | Team codengine.in